Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MY PROBLEM

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

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

Source Error:
Line 358:
Line 359: <%-- <asp:button id="btnDeleteRecord" runat="server" cssclass="YourButtonStyle" onclick="btnDeleteRecord_Click" text="Delete" commandargument="<%# Eval("ID") %>">--%>
Line 360: <asp:button id="btnDeleteRecords" text="Delete Records" onclick="btnDeleteRecords_Click" cssclass="YourButtonStyle" runat="server" onclientclick="javascript: return confirm('Do you want to delete Customer this record?')">
Line 361: Line 362:


DETAILS:

my local machine, it's working perfectly but when I uploaded it to my domain, an error occurred.

What I have tried:

My Code

frontend code /pre>
<pre> <asp:GridView ID="GridView1" Class="myGridClass" runat="server" AutoGenerateColumns="false" HorizontalAlign="Right" PageSize="10"  AllowPaging="true" OnPageIndexChanging="OnPaging" OnRowCommand="GridView1_RowCommand" OnRowDeleting="GridView1_RowDeleting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" DataKeyNames="ID">
                                    <RowStyle CssClass="gridCSS" />
                                    <AlternatingRowStyle CssClass="gridAlternateCSS" />
                                    <HeaderStyle CssClass="gridCSS" />
                                    <Columns>
										
                                        <asp:BoundField DataField="ID" HeaderText="ID" HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true" />
                                        <asp:BoundField DataField="CustomerName" HeaderText="Customer Name" HeaderStyle-Width ="100px" HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true" />
                                        <asp:BoundField DataField="Date" HeaderText="Date" DataFormatString ="{0:dd/MM/yyyy}" HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true" />
                                        <asp:BoundField DataField="withdepositconnection" HeaderText="With Dep Conn" HeaderStyle-Width ="50px" HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true" />
                                        <asp:BoundField DataField="zerodepositconnection" HeaderText="Zero Dep Conn" HeaderStyle-Width ="50px" HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true" />
                                         <asp:BoundField DataField="OpenCylinderbalance" HeaderText="Opn Cyl Bal" HeaderStyle-Width ="50px" HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true" />
                                        <asp:BoundField DataField="AmountDebit" HeaderText="Debit Amt" HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true" />
                                        <asp:BoundField DataField="AmountCredit" HeaderText="Credit Amt"  HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true"/>


                                        <asp:TemplateField HeaderText="Edit Details" ControlStyle-Font-Bold="true" ControlStyle-ForeColor="Black" HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="lnkview" runat="server" CssClass="gridCSS" ForeColor="green" Font-Bold="true" CommandArgument='<%# Eval("ID") %>' OnClick="lnk_OnClick">Edit</asp:LinkButton>
                                                <%-- <asp:ImageButton ID="ImageButton1"  ImageUrl="~/images/edit-icon.png" runat="server" Width="15" Height="15"  CommandArgument='<%# Eval("ID") %>' OnClick="lnk_OnClick"  CausesValidation="false"/>--%>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Delete" ShowHeader="False"  HeaderStyle-Font-Names="center" HeaderStyle-Font-Size="Small" HeaderStyle-Font-Bold="true">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False"
                            CommandName="Delete" OnClientClick="javascript: return confirm('Do you want to delete Customer this record?')" CommandArgument='<%# Eval("ID") %>' Text="Delete"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                                    </Columns>
                                   
                                </asp:GridView>





backend code<


protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
     {
         int ID = Convert.ToInt32(e.CommandArgument.ToString());
         if (e.CommandName == "Delete")
         {
             if (sqlCon.State == ConnectionState.Open)
             {
                 sqlCon.Close();
             }
             sqlCon.Open();
             SqlCommand sqlCmd = new SqlCommand();
             sqlCmd.Connection = sqlCon;
             sqlCmd.CommandText = "Delete from CustomerRegistration where ID=" + ID + "";
             sqlCmd.ExecuteNonQuery();
             sqlCmd.Dispose();
             sqlCon.Close();

             GridView1.DataBind();
         }
     }
     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
     {
         //int index = Convert.ToInt32(e.RowIndex);
         //DataTable dt = ViewState["dt"] as DataTable;
         //dt.Rows[index].Delete();
         //ViewState["dt"] = dt;
         //GridView1.DataSource = dtbl;
         GridView1.DataBind();
     }

     protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
     {

     }
Posted
Updated 30-Apr-21 23:51pm

1 solution

You aren't showing us the line that has the error in the context of the other code, or the appropriate methods in your C# code behind, so we can't be specific.

But the error is pretty explicit:
'ASP.customerregister_aspx' does not contain a definition for 'btnDeleteRecords_Click' and no extension method 'btnDeleteRecords_Click' accepting a first argument of type 'ASP.customerregister_aspx' could be found

You have two lines of code with similar structure, one uses btnDeleteRecords_Click and the other btnDeleteRecord_Click - are you sure that one of them isn't misspelled?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900