473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Building text box name programically

Hello,

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
possibilities?

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

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,

sck10


May 30 '06 #1
1 1278
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">
<ItemTemplate>
<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 />
</ItemTemplate>
</asp:Repeater>
=============================

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 asp.net table control)
to display the radiobuttons and each table row contains the radio buttons
associated with a certain question.

Hope this helps.

Regards,

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! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


May 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Daniel Friend | last post by:
Hello, I have added a custom usercontrol programically and all works fine... I would like to change some custom properties that I have set in that usercontrol. Any help would be greatly...
3
by: Jim | last post by:
I have a datagrid with a DataAdapter as the DataSource. The user fills in their data for 3 columns and I want to programically add a value to the 4th (invisible) column (employee number). That way...
3
by: ryanmhuc | last post by:
Is it possible to have a dynamic table name within a query or a table name that is a variable? This does not work but gives an example: SELECT * FROM concat('table', 'name') - OR - SET @table...
2
by: dtarczynski | last post by:
Hello. Im trying to add new EventHandler to DropDownList programically. Im doing something like this: DropDownList ddlCate = new DropDownList(); ddlCate.ID = String.Format("ddlCategory{0}",...
5
by: superjacent | last post by:
Hope someone can help. I have a saved parent form containing an unbound sub-form. I set the SourceObject (form) after the Parent Form opens/loads. The sub-form (datasheet view) basically...
0
by: abduzalam | last post by:
Hi Members, I am in a serious trouble,My problem is i want to develop a software as my academic project, it is network back up database, that is a remote machine hold sql databses, and when...
4
by: ramshankaryadav | last post by:
Hi, I'm facing a problem while building a project through MSBuild, this project is a part of a solution which has several other projects on which it depends, but I want to build this project...
12
kcdoell
by: kcdoell | last post by:
Hello: I just learned how to put crosstabs queries together but this one in particular is adding a new dimension in which I was hoping someone could give me some direction. I have the following...
4
by: Miner Jeff | last post by:
I need to build the name of a function from data in a text file. For example, after reading the variables 'FCTN_PREFIX' AND 'FCTN_SUFFIX' from the text file, I need to execute the function: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.