I have a delete button on a gridview
for each row that calls gvSiteInfo_RowDeleting(object sender, EventArgs e)
when it is clicked. How do I find out the value of the row number of the clicked delete button? I need to have the row number in the delete method where i specify with << NEED ROW NUMBER HERE!! >>
So far I haven't been able to turn up anything searching the web and when i print out the values of sender
and e
they don't tell me anything useful.
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>
The RowDeleting event actually takes GridViewDeleteEventArgs, not your standard EventArgs. There is a
RowIndex
property on the former that will give you the index of the row being deleted.