Я получаю сообщение об ошибке OnSelectedIndexChanging
Мой файл aspx
<asp:GridView CssClass="table table-striped table-hover" ID="product_all_detail_list" runat="server" OnSelectedIndexChanging="product_detail_list_SelectedIndexChanging" OnSelectedIndexChanged="product_all_detail_list_SelectedIndexChanged" >
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:TemplateField HeaderText="ID" Visible="false">
<ItemTemplate>
<asp:Label ID="lb_id" runat="server" Text='<%#Eval("Id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Код
protected void product_detail_list_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
Button btn = sender as Button;
// GridViewRow row = btn.NamingContainer as GridViewRow;
GridViewRow row = (GridViewRow)(((Control)sender).NamingContainer);
all_details.Visible = true;
Label id = (Label)row.FindControl("lb_id");
dal.Fillgrid(product_all_detail_list, q);
}
Код правильный?Я также пытался для GridViewRow row = btn.NamingContainer as GridViewRow;
, но получал ошибку вроде Object reference not set to an instance of an object.