0

I have a problem in event onserclick.

HTML

<asp:GridView ID="customergridview" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered"
    Width="100%" ClientIDMode="Static">
    <Columns>
        <asp:BoundField DataField="Customer ID" HeaderText="Customer ID" ReadOnly="True"
            SortExpression="Customer ID"></asp:BoundField>
        <asp:BoundField DataField="Nama Customer" HeaderText="Nama Customer" SortExpression="Nama Customer">
        </asp:BoundField>
        <asp:BoundField DataField="Alamat" HeaderText="Alamat" SortExpression="Alamat"></asp:BoundField>
        <asp:BoundField DataField="Nomor Kontak" HeaderText="Nomor Kontak" SortExpression="Nomor Kontak">
        </asp:BoundField>
        <asp:BoundField DataField="Tipe Outlet" HeaderText="Tipe Outlet" SortExpression="Tipe Outlet">
        </asp:BoundField>
        <asp:TemplateField ShowHeader="false" HeaderText="Action">
            <ItemTemplate>
                <button runat="server" id="btnedit" type="button" title="Edit"
                    onserverclick="btnedit_ServerClick"><img src="img/pencil 64.png" height="25px"></button>
                <button runat="server" id="btndelete" title="Delete" onclick="btndelete_onclick"><img
                        src="img/delete 64.png" height="25px"></button>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

I am create a btnedit event on serverside.

Server Side

private void btnedit_ServerClick(object sender, EventArgs e)
{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append("<script type='text/javascript'>");
    sb.Append("$('#EditCustomer').modal('show');");
    sb.Append("</script>");
    ScriptManager.RegisterStartupScript(this, this.GetType(), "LaunchServerSide", sb.ToString(), false);
}

but I'm having problems like this when compile.

Compiler Error Message: CS1061: 'managecustomers_aspx' does not contain a definition for 'btnedit_ServerClick' and no extension method 'btnedit_ServerClick' accepting a first argument of type 'managecustomers_aspx' could be found (are you missing a using directive or an assembly reference?)

What does this error mean? what should I correct?

Hendrick Wijaya
  • 47
  • 1
  • 2
  • 11

1 Answers1

0

That error is because your server-side method is private. Because it is private, it is not available to derived classes.

Change it to protected:

protected void btnedit_ServerClick(object sender, EventArgs e)