CheckBoxes in DataGrids-- the "checked" attribute not correct after posting page?

Discussion in 'ASP .Net Datagrid Control' started by Jim Bancroft, Jul 23, 2005.

  1. Jim Bancroft

    Jim Bancroft Guest

    Hi everyone,

    I'm using a DataGrid with TemplateColumns. My DataGrid is located in a cell
    of an asp:Table. I did this so it's positioned correctly onscreen.

    One of the DataGrid's TemplateColumns is a checkbox. During the page's
    postback I loop over the DataGrid and read the checkbox values. My problem
    is, none of the checkboxes ever have their "Checked" attribute set-- it's as
    though anything I mark is ignored.

    If I put a checkbox outside of the DataGrid, into a separate cell of my
    table, I can read its Checked attribute correctly during postback. Is there
    something I'm missing here when it comes to placing checkboxes into DataGrid
    columns? I enabled the viewstate on my checkbox, but that didn't help. If
    you have any suggestions or tips, I'm all ears. Thanks!
     
    Jim Bancroft, Jul 23, 2005
    #1
    1. Advertising

  2. Jim Bancroft

    Ting Huang Guest

    RE: CheckBoxes in DataGrids-- the "checked" attribute not correct afte

    Check if you have datagrid's viewstate enabled.
    Check if you re-bind your data in postback. If you do, the selection info
    will be lost.
    --
    Ting Huang


    "Jim Bancroft" wrote:

    >
    > Hi everyone,
    >
    > I'm using a DataGrid with TemplateColumns. My DataGrid is located in a cell
    > of an asp:Table. I did this so it's positioned correctly onscreen.
    >
    > One of the DataGrid's TemplateColumns is a checkbox. During the page's
    > postback I loop over the DataGrid and read the checkbox values. My problem
    > is, none of the checkboxes ever have their "Checked" attribute set-- it's as
    > though anything I mark is ignored.
    >
    > If I put a checkbox outside of the DataGrid, into a separate cell of my
    > table, I can read its Checked attribute correctly during postback. Is there
    > something I'm missing here when it comes to placing checkboxes into DataGrid
    > columns? I enabled the viewstate on my checkbox, but that didn't help. If
    > you have any suggestions or tips, I'm all ears. Thanks!
    >
    >
    >
     
    Ting Huang, Jul 23, 2005
    #2
    1. Advertising

  3. Jim Bancroft

    Jim Bancroft Guest

    Re: CheckBoxes in DataGrids-- the "checked" attribute not correct afte

    Yes, that was it. I had inadvertently bound my DataGrid during postback, so
    the checkboxes lost their state. Many thanks Ting!


    "Ting Huang" <> wrote in message
    news:...
    > Check if you have datagrid's viewstate enabled.
    > Check if you re-bind your data in postback. If you do, the selection info
    > will be lost.
    > --
    > Ting Huang
    >
    >
    > "Jim Bancroft" wrote:
    >
     
    Jim Bancroft, Jul 24, 2005
    #3
  4. Re: CheckBoxes in DataGrids-- the "checked" attribute not correct afte

    Yeah with CheckBoxes thats the trick
    Patrick


    "Jim Bancroft" <> wrote in message
    news:...
    > Yes, that was it. I had inadvertently bound my DataGrid during postback,

    so
    > the checkboxes lost their state. Many thanks Ting!
    >
    >
    > "Ting Huang" <> wrote in message
    > news:...
    > > Check if you have datagrid's viewstate enabled.
    > > Check if you re-bind your data in postback. If you do, the selection

    info
    > > will be lost.
    > > --
    > > Ting Huang
    > >
    > >
    > > "Jim Bancroft" wrote:
    > >

    >
    >
     
    Patrick.O.Ige, Jul 25, 2005
    #4
  5. Jim Bancroft

    GJH Guest

    Can you post your code where you check your grid for what checkbox has been
    clicked? I have a similar app where I need to check each row to see what
    radio group has been selected.

    thanks in advance


    "Jim Bancroft" <> wrote in message
    news:%...
    >
    > Hi everyone,
    >
    > I'm using a DataGrid with TemplateColumns. My DataGrid is located in a

    cell
    > of an asp:Table. I did this so it's positioned correctly onscreen.
    >
    > One of the DataGrid's TemplateColumns is a checkbox. During the page's
    > postback I loop over the DataGrid and read the checkbox values. My

    problem
    > is, none of the checkboxes ever have their "Checked" attribute set-- it's

    as
    > though anything I mark is ignored.
    >
    > If I put a checkbox outside of the DataGrid, into a separate cell of my
    > table, I can read its Checked attribute correctly during postback. Is

    there
    > something I'm missing here when it comes to placing checkboxes into

    DataGrid
    > columns? I enabled the viewstate on my checkbox, but that didn't help.

    If
    > you have any suggestions or tips, I'm all ears. Thanks!
    >
    >
     
    GJH, Aug 4, 2005
    #5
    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. Jim Bancroft
    Replies:
    4
    Views:
    880
  2. Churchy
    Replies:
    0
    Views:
    699
    Churchy
    Oct 13, 2010
  3. jmhmaine
    Replies:
    4
    Views:
    427
    Steven Cheng[MSFT]
    Jan 24, 2005
  4. tom
    Replies:
    0
    Views:
    1,391
  5. lehmann
    Replies:
    3
    Views:
    114
    lehmann G.
    Jul 1, 2003
Loading...

Share This Page