FindControl on GridView Cell returning null

Discussion in 'ASP .Net' started by saha, Jun 25, 2006.

  1. saha

    saha Guest

    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
    --
     
    saha, Jun 25, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Durzi

    OnEditCommand - .FindControl Returning Null

    George Durzi, Jul 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    502
    George Durzi
    Jul 14, 2003
  2. James G. Beldock
    Replies:
    1
    Views:
    9,381
    Kevin Spencer
    Aug 7, 2003
  3. Replies:
    5
    Views:
    27,490
    Mike Schilling
    Mar 29, 2006
  4. jason
    Replies:
    13
    Views:
    936
    John B. Matthews
    May 14, 2010
  5. George Durzi

    OnEditCommand - FindControl returning Null

    George Durzi, Jul 14, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    171
    George Durzi
    Jul 14, 2003
Loading...

Share This Page