checkbox problems in datagrid

Discussion in 'ASP .Net Datagrid Control' started by John, Jan 5, 2006.

  1. John

    John Guest

    Hi all, i've added a checkbox column to my datagrid using template columns,
    and i added a checkbox to the header for check all and uncheck all
    functionality. the purpose of this is to allow the users to select records
    from the list and add them to another list when the push a button. My
    problem is that the checked value never survives postback. in other words i
    can find the controls, i used some online articles to figure out how to do
    this, but the chkbox.checked value is always false even if i hard code it to
    be true in the html. i've tried both asp:checkbox and HtmlInputControl
    checkboxes, both have the same problem. i've also tried with and without
    paging enabled on the datagrid and nothing helps.
    heres the c# code i'm using to try to get the values

    foreach( DataGridItem di in dgListData.Items )
    {
    if(di.FindControl("chkInclude")!=null)
    Trace.Write("in foreach");
    HtmlInputCheckBox chkBx =
    (HtmlInputCheckBox)di.FindControl("chkInclude") ;

    if( chkBx !=null )
    {
    Trace.Write("In if",chkBx.Checked.ToString()+" value
    "+chkBx.Value.ToString());
    lblIncludeError.Visible=true;
    lblIncludeError.Text="It worked";
    }
    }
     
    John, Jan 5, 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. tshad
    Replies:
    0
    Views:
    576
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,429
    ThunderMusic
    Jan 25, 2006
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    863
    David Wier
    Oct 6, 2006
  4. Jason Huang
    Replies:
    0
    Views:
    583
    Jason Huang
    Jun 29, 2007
  5. Joey Pang
    Replies:
    4
    Views:
    561
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page