通过存储过程更新GridView

时间:2015-11-18 14:28:10

标签: c# asp.net gridview

所以我的GridView工作正常。我启用了“编辑”,“删除”和“更新”列。我的StoredProcedure仅选择填充GridView的数据。

我应该制作一个可以选择,更新和删除的StoredProcedure,还是使用3个独立的StoredProcedures?

如何在GridView端引用和编写更新和删除?

    <asp:SqlDataSource ID="SqlDataSourceViewRegistrants" runat="server" 
ConnectionString="<%$ ConnectionStrings:Events2 %>" 
SelectCommand="spGetRegistrantsGridView"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>

StoredProcedure(仅选择声明)

ALTER PROCEDURE [dbo].[spGetRegistrantsGridView]
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    SELECT FirstName,
        LastName,
        AddressLine1,
        AddressLine2,
        City,
        State,
        Zip,
        Country,
        Phone,
        PhoneExt,
        Email,
        Comments
    FROM Registrant
END

1 个答案:

答案 0 :(得分:1)