1
Answer

FindControl in GridView

Vikram

Vikram

14y
5.8k
1

Hi,

    In my Application, I am using User control which contains one GridView and few Buttons. GridView Contains CheckBox in Item Template of first Column for Selection purpose. Now on one of the Button's click Event I am traversing through the GridView and find which row is selected.

Following is my Code for traversing which is not working:

foreach (GridViewRow row in gvCallSheet.Rows)
        {
            CheckBox cbx = (CheckBox)row.FindControl("cbSelected");
            if (cbx.Checked)
            {
                string str = "str";
            }
        }

foreach (GridViewRow row in GridView1.Rows)

        {

            CheckBox cbx = (CheckBox)row.FindControl("cbSelected");

            if (cbx.Checked)

            {

                //do something;

            }

        }

  In normal Page its working fine for me. When I am using it in User Control its not working.

Do I miss something or anything extra require for User Control for finding Control from GridView.

Any Help Appreciated..........


Thanks,

 VIkram

Answers (1)