Checkbox within a datalist

Discussion in 'ASP .Net Web Controls' started by UJ, May 24, 2005.

  1. UJ

    UJ Guest

    I have a datalist with a checkbox in it to tell whether something is
    selected or not. Once somebody changes the checked value and I call the
    OnCheckedChanged routine, there doesn't seem to be enough information to
    figure out which row the record belongs to. I've look at the sender object
    in the debugger and it doesn't have enough to make it useful.

    What are people doing to make this work?

    TIA.

    Jeffrey.
     
    UJ, May 24, 2005
    #1
    1. Advertising

  2. UJ

    Brock Allen Guest

    Yeah, unfortunately the CheckBox doesn't bubble the event up to the DataGrid.
    You could use the sender parameter and walk up the Control.Parent tree until
    you find the DataGridItem which is the row in the table. Once you have the
    DataGridItem, you'll know the ItemIndex and then you can use that to index
    into the DataGrid's DataKey collection to get the primary key for the item.
    It's a hack, but it works.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > I have a datalist with a checkbox in it to tell whether something is
    > selected or not. Once somebody changes the checked value and I call
    > the OnCheckedChanged routine, there doesn't seem to be enough
    > information to figure out which row the record belongs to. I've look
    > at the sender object in the debugger and it doesn't have enough to
    > make it useful.
    >
    > What are people doing to make this work?
    >
    > TIA.
    >
    > Jeffrey.
    >
     
    Brock Allen, May 25, 2005
    #2
    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. Nevyn Twyll
    Replies:
    8
    Views:
    1,889
  2. tshad
    Replies:
    0
    Views:
    538
    tshad
    Apr 15, 2005
  3. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,408
    ThunderMusic
    Jan 25, 2006
  4. Replies:
    1
    Views:
    456
  5. Will

    Problem with DataList within DataList

    Will, Oct 10, 2007, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    190
    Walter Wang [MSFT]
    Oct 18, 2007
Loading...

Share This Page