Hello,
Hope you all will be fine. I am new to asp.net and creating GridView. I have added a Delete Row button and getting this error
CS1061: 'webform1_aspx' does not contain a definition for 'Grd1_onrowdeleting' and no accessible extension method 'Grd1_onrowdeleting' accepting a first argument of type 'webform1_aspx' could be found (are you missing a using directive or an assembly reference?)
My Webform1 Code:
<asp:GridView ID="Grd1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" Width="1306px"
OnRowDataBound="OnRowDataBound" OnRowDeleting="Grd1_onrowdeleting" >
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
webform.aspx.cs code :
public void Grd1_onrowdeleting(object sender, GridViewDeleteEventArgs e)
{
int index = Convert.ToInt32(e.RowIndex);
DataTable dt = ViewState["dt"] as DataTable;
dt.Rows[index].Delete();
ViewState["dt"] = dt;
Gbind();
}
Thanks in advance