Results 1 to 6 of 6

Thread: [RESOLVED] DataGrid Checkbox Column Unchecked!!

  1. #1

    Thread Starter
    Addicted Member NinaWilliam's Avatar
    Join Date
    May 2005
    Location
    @Home
    Posts
    133

    Resolved [RESOLVED] DataGrid Checkbox Column Unchecked!!

    Hi there,

    I am working on a datagrid that has a column with checkboxes… the checkboxes should be checked when the page loaded. The problem is that whenever I trigger a postback, all the checkboxes will be unchecked!!

    I don’t know what is causing this or what should I do to prevent it from unchecking the checkboxes.

    Any idea?
    Happy Programming

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: DataGrid Checkbox Column Unchecked!!

    Nina,

    We are going to need more information than what you have given there.

    Are the checkboxes tied to back end data, or are you simply looping through them when the page posts back?

    Can you show the code/markup that you are using?

    Gary

  3. #3
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: DataGrid Checkbox Column Unchecked!!

    Quote Originally Posted by NinaWilliam View Post
    Hi there,

    I am working on a datagrid that has a column with checkboxes… the checkboxes should be checked when the page loaded. The problem is that whenever I trigger a postback, all the checkboxes will be unchecked!!

    I don’t know what is causing this or what should I do to prevent it from unchecking the checkboxes.

    Any idea?
    If you are checking the checkboxes by coding, then the data binding to the textbox should occur in If not Page.PostBack method.

    If you are having your method in page load method without

    Code:
    If Not Page.IsPostBack Then 
       'Binding code
    End if
    Then the grid will repopulate the data and the checked state will lost..

    Hope this helps
    Please mark you thread resolved using the Thread Tools as shown

  4. #4

    Thread Starter
    Addicted Member NinaWilliam's Avatar
    Join Date
    May 2005
    Location
    @Home
    Posts
    133

    Re: DataGrid Checkbox Column Unchecked!!

    Thank you guys for your reply ^_^

    I was doing something wrong in the code *_*

    These lines solved it

    Dim chkSelected As CheckBox = e.Item.FindControl("chkSelection")
    chkSelected.Checked = True

    Have a nice day
    Happy Programming

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] DataGrid Checkbox Column Unchecked!!

    When using FindControl, you should always do a null/nothing check before accessing the members of that object, otherwise you might get an exception.

    Gary

  6. #6

    Thread Starter
    Addicted Member NinaWilliam's Avatar
    Join Date
    May 2005
    Location
    @Home
    Posts
    133

    Re: [RESOLVED] DataGrid Checkbox Column Unchecked!!

    Thank you Gary ^__^
    I appreciate your advice.

    Have a good day
    Happy Programming

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width