Link to home
Start Free TrialLog in
Avatar of nuvium
nuvium

asked on

Creating dynamic radiobuttonlist from datatable in vb.net

Hi guys, I need help with creating a dynamic radiobuttonlist. There is a radiobuttonlist that sits as an empty control. I am creating a datatable from a stored procedure, and then looping through the rows adding a new radiobutton with each passthrough. This works fine, no problems. The only thing is the actual value of each radiobutton is the actual text of the question that is getting populated. Here is the current population code :      

Dim i As Integer
        For i = 0 To dt.Rows.Count - 1
            Dim dr As DataRow = dt.Rows(i)
            rdlQuestions.Items.Add(dr.Item("LongQuestionText"))
        Next

Now what I need to do differently is this. I need to generate this radiobuittonlist dynamically, making the text of the radio button choice this : dr.Item("LongQuestionText"). I also need to make the value of the radiobutton this : dr.Item("PortalOfferID"). How can I do this?

To clarify if the "LongQuestionText" is "What is my name?" Then I get a radio button that looks like this in code : <input id="rdlQuestions_0" type="radio" name="rdlQuestions" value="What is my name?"/><label for="rdlQuestions_0">IWhat is my name?</label>. I need to somehow tie that PortalOfferID to the radiobutton so that I can write code against it.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial