Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Actually i want to find the control while editing on grid view where the control is not in edit template the control is in itemtemplate is it possible to find the control.

C#
protected void GridView1_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {


            }
}
Posted
Updated 23-May-13 1:30am
v3

Hi ntitish,

For now, please try this only if your records count is less than 30 odd.

C#
int id = (int)GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value;

for (int i = 0; i < GridView1.Rows.Count; i++)
{
    if ((int)GridView1.DataKeys[i].Value == id)
    {
        Control ctrl = (Control)GridView1.Rows[i].FindControl("XXXXXXX");
    }
}


This way you can get the control, but if your record count is too high, then will have to figure out another option due to the for loop used.

Thank you,
Vamsi
 
Share this answer
 
we can find all controls in gridview updating event from that i finded the particular control
 
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