Vikram

Vikram

  • 1.5k
  • 276
  • 308.4k

FindControl in GridView

Jun 3 2010 1:32 PM

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)