By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,052 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,052 IT Pros & Developers. It's quick & easy.

Building text box name programically

P: n/a

I am inserting the values for radio buttons on a form into a database.
There are 25 questions with 4 possible answers (see below). Is it possible
to pragmatically build the radio button name so I can loop through the

For example I would like to be able to build the rbn [01 - 25] in a loop

If Me.rbn01q01.Checked = True Then strRad01 = "Poor"
If Me.rbn01q02.Checked = True Then strRad01 = "Satisfactory"
If Me.rbn01q03.Checked = True Then strRad01 = "Good"
If Me.rbn01q04.Checked = True Then strRad01 = "Excellent"
If Len(strRad01) <> 0 Then Call DBInsertUpdate("sp_web_Survey",
strDateStamp, Me.lblQ01.Text, strRad01)
If Me.rbn25q01.Checked = True Then strRad25 = "Poor"
If Me.rbn25q02.Checked = True Then strRad25 = "Satisfactory"
If Me.rbn25q03.Checked = True Then strRad25 = "Good"
If Me.rbn25q04.Checked = True Then strRad25 = "Excellent"
If Len(strRad25) <> 0 Then Call DBInsertUpdate("sp_web_Survey",
strDateStamp, Me.lblQ01.Text, strRad25)

Thanks in advance,


May 30 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Hi Sck10,

Thank you for posting in the ASP.NET newsgroup.

From your description, I understand you're building an ASP.NET web page
which contains many radio buttons and these radio buttons are associated to
many "survey questions"(four buttons per question. Currently you're
wondering how to programmatically loop through all those radio buttons on
the page and save their status information into backend database, correct?

Based on my experience, you can consider using template databound control
to display those radio buttons (grouped by survey questions). This is
because template databound control support displaying list of control
region through databinding. Therefore, in your case, you can put four radio
buttons in the template databound control's Template and bind it with a
datasource which contains the survey question list. e.g.

<asp:Repeater ID="Repeater1" runat="server">
<br /><asp:Label ID="lblQuestion" runat="server" Text='<%#
Eval("Question") %>'></asp:Label><br />

<asp:RadioButton ID="a1" Text="Answer 1" runat="server" />
<asp:RadioButton ID="a2" Text="Answer 2" runat="server" />
<asp:RadioButton ID="a3" Text="Answer 3" runat="server" />
<asp:RadioButton ID="a4" Text="Answer 4" runat="server" />
<br /><hr />

The above repeater control uses the "ItemTemplate" to define the control
region for each survey question. You can simply generate a datasource
containing all the questions and bind it to the repeater at runtime. Also,
if you need further customization on the repeater or each repeater item,
you can use the "ItemDataBound" event.

In addition, if you don't want to use databinding based solution, you can
also consider using the table control (html table or table control)
to display the radiobuttons and each table row contains the radio buttons
associated with a certain question.

Hope this helps.


Steven Cheng
Microsoft Online Community Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure!
(This posting is provided "AS IS", with no warranties, and confers no

May 31 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.