TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Spini in
NA
4
3.1k
How to solve the compiler error CS1061 'GridView1_RowCommand'
May 3 2021 12:08 PM
My PROBLEM:
my local machine, it's working perfectly but when I uploaded it to my domain, an error occurred.
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 'GridView1_RowCommand' and no extension method 'GridView1_RowCommand' 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 322: <td > Line 323: <asp:Label ID="Nodata" runat ="server" Visible="false" Text="please add the data" ForeColor ="Red" Font-Bold ="true" Font-Size ="X-Large"></asp:Label> Line 324: <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"> Line 325: <RowStyle CssClass="gridCSS" /> Line 326: <AlternatingRowStyle CssClass="gridAlternateCSS" />
What I have tried
Frontend code:
<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) { }
Reply
Answers (
1
)
Active Directory Authentication and asp.NET identity
asp.net core javascript not working properly