Accessing dynamic radio buttons

Discussion in 'ASP .Net Web Controls' started by UJ, Jun 9, 2005.

  1. UJ

    UJ Guest

    I have a placeholder where I dynamically add radio buttons based on values
    from a DB. It's all one group. How can I access them so that I know which
    one is selected?

    I've tried both input type="radio" and asp:radiobutton

    I can't seem to add a checked.changed event to the radiobutton and when I
    search through the assorted controls on the page, I can't find the control
    anywhere (through code.)

    TIA - Jeffrey.
     
    UJ, Jun 9, 2005
    #1
    1. Advertising

  2. UJ

    Brock Allen Guest

    This is all possible. When there is a postback you need to recreate the same
    controls that you had previouly dynamically created. Here's a sample that
    shuld get you started:

    http://groups-beta.google.com/group...450?q=brock dynamic controls viewstate&rnum=1

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



    > I have a placeholder where I dynamically add radio buttons based on
    > values from a DB. It's all one group. How can I access them so that I
    > know which one is selected?
    >
    > I've tried both input type="radio" and asp:radiobutton
    >
    > I can't seem to add a checked.changed event to the radiobutton and
    > when I search through the assorted controls on the page, I can't find
    > the control anywhere (through code.)
    >
    > TIA - Jeffrey.
    >
     
    Brock Allen, Jun 9, 2005
    #2
    1. Advertising

  3. UJ

    UJ Guest

    Brock,
    Thanks I think. But that doesn't really answer my question. I have the
    creation of the radiobuttons working fine. The problem is - I need to know
    which radio button is selected.

    Any suggestions?

    TIA.

    "Brock Allen" <> wrote in message
    news:...
    > This is all possible. When there is a postback you need to recreate the
    > same controls that you had previouly dynamically created. Here's a sample
    > that shuld get you started:
    >
    > http://groups-beta.google.com/group...450?q=brock dynamic controls viewstate&rnum=1
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >> I have a placeholder where I dynamically add radio buttons based on
    >> values from a DB. It's all one group. How can I access them so that I
    >> know which one is selected?
    >>
    >> I've tried both input type="radio" and asp:radiobutton
    >>
    >> I can't seem to add a checked.changed event to the radiobutton and
    >> when I search through the assorted controls on the page, I can't find
    >> the control anywhere (through code.)
    >>
    >> TIA - Jeffrey.
    >>

    >
    >
    >
     
    UJ, Jun 9, 2005
    #3
  4. UJ

    Brock Allen Guest

    When you dynamically create them handle the SelectedindexChanged event. The
    first paramater is the sender of the event, which will be your RadioButtonList.
    Or am I still missing what you're trying to do?

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



    > Brock,
    > Thanks I think. But that doesn't really answer my question. I have the
    > creation of the radiobuttons working fine. The problem is - I need to
    > know
    > which radio button is selected.
    > Any suggestions?
    >
    > TIA.
    >
    > "Brock Allen" <> wrote in message
    > news:...
    >
    >> This is all possible. When there is a postback you need to recreate
    >> the same controls that you had previouly dynamically created. Here's
    >> a sample that shuld get you started:
    >>
    >> http://groups-beta.google.com/group/microsoft.public.dotnet.framework
    >> .aspnet/browse_thread/thread/5e4ba4cfe5902a4b/a5717a97bd32c450?q=broc
    >> k+dynamic+controls+viewstate&rnum=1
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>> I have a placeholder where I dynamically add radio buttons based on
    >>> values from a DB. It's all one group. How can I access them so that
    >>> I know which one is selected?
    >>>
    >>> I've tried both input type="radio" and asp:radiobutton
    >>>
    >>> I can't seem to add a checked.changed event to the radiobutton and
    >>> when I search through the assorted controls on the page, I can't
    >>> find the control anywhere (through code.)
    >>>
    >>> TIA - Jeffrey.
    >>>
     
    Brock Allen, Jun 9, 2005
    #4
  5. UJ

    UJ Guest

    I'm not using a radiobuttonlist - I have a series of radio buttons. The
    reason for the individual radio buttons is that I need more layout control
    than what a radiobuttonlist will give me.

    "Brock Allen" <> wrote in message
    news:...
    > When you dynamically create them handle the SelectedindexChanged event.
    > The first paramater is the sender of the event, which will be your
    > RadioButtonList. Or am I still missing what you're trying to do?
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >> Brock,
    >> Thanks I think. But that doesn't really answer my question. I have the
    >> creation of the radiobuttons working fine. The problem is - I need to
    >> know
    >> which radio button is selected.
    >> Any suggestions?
    >>
    >> TIA.
    >>
    >> "Brock Allen" <> wrote in message
    >> news:...
    >>
    >>> This is all possible. When there is a postback you need to recreate
    >>> the same controls that you had previouly dynamically created. Here's
    >>> a sample that shuld get you started:
    >>>
    >>> http://groups-beta.google.com/group/microsoft.public.dotnet.framework
    >>> .aspnet/browse_thread/thread/5e4ba4cfe5902a4b/a5717a97bd32c450?q=broc
    >>> k+dynamic+controls+viewstate&rnum=1
    >>>
    >>> -Brock
    >>> DevelopMentor
    >>> http://staff.develop.com/ballen
    >>>> I have a placeholder where I dynamically add radio buttons based on
    >>>> values from a DB. It's all one group. How can I access them so that
    >>>> I know which one is selected?
    >>>>
    >>>> I've tried both input type="radio" and asp:radiobutton
    >>>>
    >>>> I can't seem to add a checked.changed event to the radiobutton and
    >>>> when I search through the assorted controls on the page, I can't
    >>>> find the control anywhere (through code.)
    >>>>
    >>>> TIA - Jeffrey.
    >>>>

    >
    >
    >
     
    UJ, Jun 10, 2005
    #5
  6. UJ

    Brock Allen Guest

    So you can handle the OnCheckChanged event for the RadioButton, and in the
    event handler the first parameter is the sender which is the RadioButton
    that was checked. I hope this helps?

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



    > I'm not using a radiobuttonlist - I have a series of radio buttons.
    > The reason for the individual radio buttons is that I need more layout
    > control than what a radiobuttonlist will give me.
    >
    > "Brock Allen" <> wrote in message
    > news:...
    >
    >> When you dynamically create them handle the SelectedindexChanged
    >> event. The first paramater is the sender of the event, which will be
    >> your RadioButtonList. Or am I still missing what you're trying to do?
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>> Brock,
    >>> Thanks I think. But that doesn't really answer my question. I have
    >>> the
    >>> creation of the radiobuttons working fine. The problem is - I need
    >>> to
    >>> know
    >>> which radio button is selected.
    >>> Any suggestions?
    >>> TIA.
    >>>
    >>> "Brock Allen" <> wrote in message
    >>> news:...
    >>>
    >>>> This is all possible. When there is a postback you need to recreate
    >>>> the same controls that you had previouly dynamically created.
    >>>> Here's a sample that shuld get you started:
    >>>>
    >>>> http://groups-beta.google.com/group/microsoft.public.dotnet.framewo
    >>>> rk
    >>>> .aspnet/browse_thread/thread/5e4ba4cfe5902a4b/a5717a97bd32c450?q=br
    >>>> oc k+dynamic+controls+viewstate&rnum=1
    >>>>
    >>>> -Brock
    >>>> DevelopMentor
    >>>> http://staff.develop.com/ballen
    >>>>> I have a placeholder where I dynamically add radio buttons based
    >>>>> on values from a DB. It's all one group. How can I access them so
    >>>>> that I know which one is selected?
    >>>>>
    >>>>> I've tried both input type="radio" and asp:radiobutton
    >>>>>
    >>>>> I can't seem to add a checked.changed event to the radiobutton and
    >>>>> when I search through the assorted controls on the page, I can't
    >>>>> find the control anywhere (through code.)
    >>>>>
    >>>>> TIA - Jeffrey.
    >>>>>
     
    Brock Allen, Jun 10, 2005
    #6
    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. Antonietta Tobito via JavaKB.com

    Dynamic radio buttons matrix using Struts

    Antonietta Tobito via JavaKB.com, Feb 2, 2005, in forum: Java
    Replies:
    2
    Views:
    3,379
    Wendy S
    Feb 2, 2005
  2. Scott D Johnson
    Replies:
    1
    Views:
    1,096
    Scott D Johnson
    Sep 27, 2006
  3. Saul
    Replies:
    22
    Views:
    381
    Thomas 'PointedEars' Lahn
    May 16, 2006
  4. Dr. Leff
    Replies:
    3
    Views:
    312
    David Mark
    Oct 15, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    240
    David Mark
    Oct 15, 2007
Loading...

Share This Page