Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   FindControl on GridView Cell returning null (http://www.velocityreviews.com/forums/t300870-findcontrol-on-gridview-cell-returning-null.html)

saha 06-25-2006 06:50 PM

FindControl on GridView Cell returning null
 
Group,

This is the problem I am facing (VS2005):

- I do a GridView1.DataSource = DataTable and GridView1.DataBind()
- then I add checkbox coltrols to a selected few cells of the GridView:

CheckBox cb = new checkBox();
cb.ID = "cbSelect";
GridView1.Rows[j].Cells[k].Controls.Add(cb);

Every thing works fine and I am able to see the checkboxes on screen.
The user is suppose to select the checkbox, which ever is applicable
and is suppose to click a button for further processing.

On click of the button, I try to fetch the checkBoxes by doing
FindControl on the appropriate cells:

CheckBox cb =
(CheckBox)GridView1.Rows[j].Cells[k].FindControl("cbSelect");

But I always get cb as null. Any idea what might be wrong here ?
Yes, on button click, I check for the controls *before* reassigning the
datasource again.

saha
--



All times are GMT. The time now is 02:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.