473,666 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Che cked = True Then strRad01 = "Poor"
If Me.rbn01q02.Che cked = True Then strRad01 = "Satisfacto ry"
If Me.rbn01q03.Che cked = True Then strRad01 = "Good"
If Me.rbn01q04.Che cked = True Then strRad01 = "Excellent"
If Len(strRad01) <> 0 Then Call DBInsertUpdate( "sp_web_Survey" ,
strDateStamp, Me.lblQ01.Text, strRad01)
....
If Me.rbn25q01.Che cked = True Then strRad25 = "Poor"
If Me.rbn25q02.Che cked = True Then strRad25 = "Satisfacto ry"
If Me.rbn25q03.Che cked = True Then strRad25 = "Good"
If Me.rbn25q04.Che cked = 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 1289
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 programmaticall y 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:RadioButto n ID="a1" Text="Answer 1" runat="server" />
<asp:RadioButto n ID="a2" Text="Answer 2" runat="server" />
<asp:RadioButto n ID="a3" Text="Answer 3" runat="server" />
<asp:RadioButto n ID="a4" Text="Answer 4" runat="server" />
<br /><hr />
</ItemTemplate>
</asp:Repeater>
=============== ==============

The above repeater control uses the "ItemTempla te" 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 "ItemDataBo und" 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
1675
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 appreciated!!!! Thanks,
3
1796
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 when the user saves the data I can use the data already in the datagrid. Typically the user will add several rows before the DataSet.HasChanges is called and the DataAdapter.Update(AllChanges) is called. I want to add an employee number to each...
3
52331
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 = 'a'; SELCT * FROM @table Of course the query can be constructed dynamically but does not exactly
2
1814
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}", i++); ddlCate.DataSource = tblSub1; ddlCate.DataTextField = tblSub1.Columns.ColumnName; ddlCate.DataValueField =
5
2589
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 displays the results of a cross-tab query The cross-tab query is created dynamically (in code) as the column headings are subject to change. I therefore have to create a new form (in code) and add the necessary
0
1229
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 i send a request to the remote machine, the software finds the no.of databse (sql)in & it display in the local sys and want to backup and store in the local machine, so my qns is how programically backup and restore an sql databse...my front end...
4
3351
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 without building it's dependencies. We can do this for a solution by unselecting projects through Configuration Manager under solution properties, but how to achive same for a project!
12
2455
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 tables The Tables: Table Name = tblStaticAllForecast Field Type IndexInfo
4
1424
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: FCTN_PREFIX & 'TXT1' & FCTN_SUFFIX & 'TXT2'; where TXT1 and TXT2 are hardcoded text; & indicates concatenation. I assume I could concatenate the text to build the function name and give it a variable name but how can I then execute that function?
0
8362
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8878
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8644
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6200
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.