Findcontrols in Grdiview For Particular Row: Gridviewrow Label Label Label Textbox Textbox Textbox
Findcontrols in Grdiview For Particular Row: Gridviewrow Label Label Label Textbox Textbox Textbox
In grdiview
For particular row
GridViewRow row = gridCategory.Rows[gridCategory.SelectedIndex];
Label lblnam = (Label)(row.FindControl("lblname") as Label);
TextBox txtVar=(TextBox )(row .FindControl ("TextBox1") as TextBox) ;
txtcategoryname.Text = lblnam.Text;
GridView control stores data keys as a collection and this collection is called the DataKeys collection.
This DataKeys collection is exposed by the GridView control's DataKeys property. We retrieve the data
key associated with a selected row by using the statement:
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
This statement returns the value of the data key associated with the selected row of the gridView
control.
Here, we have assigned multiple data keys to DataKeyNames property. So we can use a statement
that looks like this: