Using a RadioButtonList in a dynamic table

Discussion in 'ASP .Net Web Controls' started by Rob, Sep 6, 2004.

  1. Rob

    Rob Guest

    Does anyone have an idea on how to do this?
    I have a query that dynamicaly creates RadioButtonLists and I need to
    set each radio button in a dynamic cell of a table. Here's my code:

    Dim dr As SqlDataReader =
    cm.ExecuteReader(CommandBehavior.CloseConnection)
    Do While dr.Read
    'initialize the radiobuttonlist
    rbList = New RadioButtonList
    rbList.ID = dr.GetInt32(0)

    tr = New TableRow
    'add an image for the visitor to the cell
    vImage = New Image
    vImage.ImageUrl = "images/teams/" & dr.GetString(4)
    tdVimage = New TableCell
    tdVimage.Controls.Add(vImage)
    tr.Controls.Add(tdVimage)

    td1 = New TableCell
    rbList.DataValueField = dr.GetInt32(6)
    rbList.Items.Add(New ListItem(dr.GetString(2)))
    td1.Controls.Add(rbList)
    tr.Controls.Add(td1)

    td2 = New TableCell
    rbList.DataValueField = dr.GetInt32("0")
    rbList.Items.Add(New ListItem("Tie"))
    td2.Controls.Add(rbList)
    tr.Controls.Add(td2)


    'add an image for the home team
    hImage = New Image
    hImage.ImageUrl = "images/teams/" & dr.GetString(5)
    tdHimage = New TableCell
    tdHimage.Controls.Add(hImage)
    tr.Controls.Add(tdHimage)

    td3 = New TableCell
    rbList.DataValueField = dr.GetInt32(7)
    rbList.Items.Add(New ListItem(dr.GetString(3)))
    td3.Controls.Add(rbList)
    tr.Controls.Add(td3)

    'add all controls to the table
    tblPlayGames.Controls.Add(tr)

    Loop


    The problem is that I need to display images in the cells that
    correspond to the data being displayed so just populating a
    RadioButtonList won't work and I can't seem to display one radio button
    per table cell. The code above displays all radio buttons in one cell.

    Any ideas anyone?

    Thanks
    Rob




    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Rob, Sep 6, 2004
    #1
    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. Brian
    Replies:
    2
    Views:
    547
    Brian Ciarcia
    Feb 23, 2005
  2. Mike Salter
    Replies:
    5
    Views:
    4,270
  3. Hugo Flores

    Dynamic RadioButtonList problem

    Hugo Flores, Jul 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    3,227
    Hugo Flores
    Jul 20, 2005
  4. Replies:
    0
    Views:
    461
  5. Michael Christensen

    Datagrid - dynamic radiobuttonlist problems...

    Michael Christensen, Oct 7, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    142
    Saravana [MVP]
    Oct 7, 2003
Loading...

Share This Page