Gridview Control Coding
I am using Gridview control in Asp.Net.I have inserted data in one page and in another I am using Gridview control. In that I can Select,Delete Gridview. But I can't Update data.Can anyone help me?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pradeep ShetPosted Jul 9, 2014, 2:43 AM
You can do 1 thing in simple way,
1)In case of Update click in a gridview, first of all set the CommandArgument property of button with the primarykeyId
Like,
2) OnRowCommand event of grid, check for the CommandName="UpdateMyData"
if(e.CommandName == "UpdateMyData")
{
string id = e.CommandArgument.toString();
Response.Redirect("InsertPage.aspx?id=" + id);
}
3)In InsertPage.aspx, on page_load event check for querystring value and load the data
if(Request.QueryString["id"] != null)
{
LoadData();
string mode= "update";
}
I hope this will help you to solve your problem. If you think it as helpful please mark it Like.