Reputation: 83
I am having an issues trying to update different columns in a Gridview separately.
Below is a picture which shows the two columns, after the the edit button has been pressed. Both is editable, and both buttons have turned into the usual Update/Cancel buttons.
I need to be able to update the specific column based on what update button i press in this code:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
*some code*
}
I've tried using onclick for one field and the commandArgument for the other, but I am having trouble getting the rowIndex and fieldValue using an onclick.
Thanks for any help!
Upvotes: 0
Views: 47
Reputation: 13965
You could use the RowCommand
event, and use separate CommandName
values for the two update buttons.
protected void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{
switch(e.CommandName)
{
case "Update1":
// handle things
break;
case "Update2":
// handle things
break;
}
}
However, using custom CommandName
values will probably require you to write your own handler for the Update
function, the way you would with any other custom GridView
button.
Upvotes: 1