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

Discussion in 'ASP .Net' 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. 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!
    >
    >
    >
    =?Utf-8?B?VGluZyBIdWFuZw==?=, 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. Churchy
    Replies:
    0
    Views:
    682
    Churchy
    Oct 13, 2010
  2. Jim Bancroft
    Replies:
    4
    Views:
    167
  3. jmhmaine
    Replies:
    4
    Views:
    414
    Steven Cheng[MSFT]
    Jan 24, 2005
  4. tom
    Replies:
    0
    Views:
    1,369
  5. lehmann
    Replies:
    3
    Views:
    108
    lehmann G.
    Jul 1, 2003
Loading...

Share This Page