DataKey from a gridview
-
Hi there, I am in a problem..like i have one gridview and the DataKeyNames is say "ID" i have one imagebutton field for changin the status of a customer in that image button i setup one commandargument field say "StatusValue"..and the CommandName is Status... when i click status button ie, in the "GridView1_RowCommand" event i need both the values ie ID and StatusValue corresponding to that row.... Can anybody give me a help to solve this... i am using asp.net 2.0 and c#
-
Hi there, I am in a problem..like i have one gridview and the DataKeyNames is say "ID" i have one imagebutton field for changin the status of a customer in that image button i setup one commandargument field say "StatusValue"..and the CommandName is Status... when i click status button ie, in the "GridView1_RowCommand" event i need both the values ie ID and StatusValue corresponding to that row.... Can anybody give me a help to solve this... i am using asp.net 2.0 and c#
Use the gridviews rowdatabound event.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{// on each row which is DataRow populate dropdown lists if (e.Row.RowType == DataControlRowType.DataRow) { Button Button1 = (Button)e.Row.FindControl("Button1"); //could be dbdatarecords (for datareader) or other object You may have to modify this DataRowView drv = (DataRowView)e.Row.DataItem; // Add values to button Button1.attributes.add("id", dvr\["id"\].tostring()); } }
I didn't get any requirements for the signature
-
Use the gridviews rowdatabound event.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{// on each row which is DataRow populate dropdown lists if (e.Row.RowType == DataControlRowType.DataRow) { Button Button1 = (Button)e.Row.FindControl("Button1"); //could be dbdatarecords (for datareader) or other object You may have to modify this DataRowView drv = (DataRowView)e.Row.DataItem; // Add values to button Button1.attributes.add("id", dvr\["id"\].tostring()); } }
I didn't get any requirements for the signature
hi thanks for your response..but i coudn't able to come up with a result...i set the attributes with id value but how can i retrieve those values...now i have command arguemnet in image button and the id value is in imagebutton's ID value..so how can i retrieve those values in row command u have any idea. regards alex.
-
hi thanks for your response..but i coudn't able to come up with a result...i set the attributes with id value but how can i retrieve those values...now i have command arguemnet in image button and the id value is in imagebutton's ID value..so how can i retrieve those values in row command u have any idea. regards alex.
Button button1 = (button)sender; button1.attribute["ID"].value ?
I didn't get any requirements for the signature
-
Button button1 = (button)sender; button1.attribute["ID"].value ?
I didn't get any requirements for the signature
Hi, No that's not possible..because gridview is the sender....because image button is inside the gridview..i tried but it makes error.... regards alex
-
Hi, No that's not possible..because gridview is the sender....because image button is inside the gridview..i tried but it makes error.... regards alex
Sorry, I guess I usually used an item template column. You should still be able to determine the gridviewrow and use its findcontrol method. If that doesn't work you could pass both values as the command argument and use string.split. I'm sure you can figure it out.
I didn't get any requirements for the signature
-
Sorry, I guess I usually used an item template column. You should still be able to determine the gridviewrow and use its findcontrol method. If that doesn't work you could pass both values as the command argument and use string.split. I'm sure you can figure it out.
I didn't get any requirements for the signature
Hi, Thanks man finally it works..i used both values in the command arguement and split it out... thanks once again. regards alex.