0

gridview我在单击时调用的每一行都有一个删除按钮gvSiteInfo_RowDeleting(object sender, EventArgs e)。如何找出单击的删除按钮的行号值?我需要在我指定的删除方法中有行号<< NEED ROW NUMBER HERE!! >>

到目前为止,我无法在网上搜索到任何东西,当我打印出的值时sendere它们并没有告诉我任何有用的信息。

 protected void gvSiteInfo_RowDeleting(object sender, EventArgs e)
    {

        SiteDB site = new SiteDB();
        site.SelectedConnectionString = "SQLDEV08";
        site.deleteSite(<<<NEED ROW NUMBER HERE!!>>>);
    }

<asp:GridView ID="gvSiteInfo" runat="server" AutoGenerateColumns="False" OnSorting="gvSiteInfo_Sorting" width="100%"
    AllowSorting="True" OnRowDeleting="gvSiteInfo_RowDeleting" >
    <Columns>
        <asp:CommandField ButtonType="Button" ShowDeleteButton="True" ShowCancelButton="True" />
        <asp:BoundField DataField="prodServer" HeaderText="Production Server" 
            SortExpression="prodServer" />
        <asp:BoundField DataField="prodIP" HeaderText="Production IP Address" 
            SortExpression="prodIP" />
        <asp:BoundField DataField="Priority" HeaderText="Priority" 
            SortExpression="Priority" />
        <asp:BoundField DataField="Platform" HeaderText="Platform" 
            SortExpression="Platform" />
    </Columns>
</asp:GridView>
4

1 回答 1

4

RowDeleting 事件实际上采用GridViewDeleteEventArgs,而不是您的标准 EventArgs。前者有一个RowIndex属性可以为您提供被删除行的索引。

于 2012-08-14T19:51:54.710 回答