Click here to Skip to main content
15,895,786 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have gridview as follows

ID Name Season Actions

14756 Test1 2018 Edit Delete
22089 Test2 2018 Edit Delete
33571 Test3 2018 Edit Delete
17912 Test4 2018 Edit Delete


When i click the edit link button in the first row it will redirect to farmermasterpage but when i click edit link button in the third row it does not redirect to farmermasterpage.


Edit code as follows


ASP.NET
if (e.CommandName == "Edit")
{
Response.Redirect("~/ivorycoast/farmermaster.aspx?action=edit&farmercode=" + e.CommandArgument.ToString() ,false);
}
 
Gridview source .aspx page code as follows
 
<asp:TemplateField HeaderText="Actions">
<itemtemplate>
<asp:LinkButton ID="lnkEdit" runat="server" ToolTip="Click to edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "farmerctscode") %>' CommandName="Edit" OnCommand="onCommand">
| 
<asp:LinkButton ID="lnkDelete" runat="server" ToolTip="Click to edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "farmerctscode") %>' CommandName="Delete" OnCommand="onCommand">




when i run the above code shows error as follows

The GridView 'grdFarmerList' fired event RowEditing which wasn't handled.

Note : for response.redirect i added false.

Response.Redirect("~/ivorycoast/farmermaster.aspx?action=edit&farmercode=" + e.CommandArgument.ToString() ,false);

what is the mistake in my above code.

What I have tried:

I have gridview as follows

ID Name Season Actions
C#



14756 Test1 2018 Edit Delete
22089 Test2 2018 Edit Delete
33571 Test3 2018 Edit Delete
17912 Test4 2018 Edit Delete


When i click the edit link button in the first row it will redirect to farmermasterpage but when i click edit link button in the third row it does not redirect to farmermasterpage.


Edit code as follows


HTML
if (e.CommandName == "Edit")
{
Response.Redirect("~/ivorycoast/farmermaster.aspx?action=edit&farmercode=" + e.CommandArgument.ToString() ,false);
}


Gridview source .aspx page code as follows

ASP.NET
<asp:TemplateField HeaderText="Actions">
<itemtemplate>
<asp:LinkButton ID="lnkEdit" runat="server" ToolTip="Click to edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "farmerctscode") %>' CommandName="Edit" OnCommand="onCommand">
| 
<asp:LinkButton ID="lnkDelete" runat="server" ToolTip="Click to edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "farmerctscode") %>' CommandName="Delete" OnCommand="onCommand">




when i run the above code shows error as follows

The GridView 'grdFarmerList' fired event RowEditing which wasn't handled.

Note : for response.redirect i added false.

C#
Response.Redirect("~/ivorycoast/farmermaster.aspx?action=edit&farmercode=" + e.CommandArgument.ToString() ,false);


what is the mistake in my above code.
Posted
Updated 31-May-18 21:47pm
v2

1 solution

Because the commandname is Edit the gridView expects to call the RowEditing event.
Define that Event and put the code you need there.
A small search on MSDN is pretty clear about that: GridView.RowCommand Event (System.Web.UI.WebControls)[^]
 
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