473,403 Members | 2,183 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,403 software developers and data experts.

How do I group the TextBox controls and get their values in codebehind pages?

Hi there,
I have 10 text boxes defined to insert their values into the database.
How do I group all of these text boxes? I mean provide a common name to
the group and try access the values in the code behind page using For I
= 1 to 10 Next loop.

For instance the text boxes I have now are as below

_txtOptionText1
_txtOptionText2
_txtOptionText3
....
_txtOptionText10

I don't know of any property so that I can group them and access the
group in the code behind page.

Any input is appriciated,
-L

May 23 '06 #1
5 906
How about something like

ddlAddress.Attributes.Item("MyAttribute") = strAttrib

"Learner" <pr****@gmail.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Hi there,
I have 10 text boxes defined to insert their values into the database.
How do I group all of these text boxes? I mean provide a common name to
the group and try access the values in the code behind page using For I
= 1 to 10 Next loop.

For instance the text boxes I have now are as below

_txtOptionText1
_txtOptionText2
_txtOptionText3
...
_txtOptionText10

I don't know of any property so that I can group them and access the
group in the code behind page.

Any input is appriciated,
-L

May 23 '06 #2
Hello Jeff,
I am sorry I don't understand what you are trying to explain. Could you
please take another moment to explain it a little.
Thanks,
-L

May 23 '06 #3
how about

dim myControl as string
dim i as integer
dim currentTextBox as textbox
mycontrol="txtOptionText"

for i = 1 to 10
currentTextBox = page.FindControl(myControl & i)
currentTextBox.text = "Value " & i
next i

May 23 '06 #4
Did you try it? I'm just suggesting, create your own attribute. Essentially
your own property.

Jeff

"Learner" <pr****@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hello Jeff,
I am sorry I don't understand what you are trying to explain. Could you
please take another moment to explain it a little.
Thanks,
-L

May 23 '06 #5
Hello Friends,
This is how finally I got it working :) . We use Master pages in our
application so I had to use FindControl to find the contentplaceholder
and then the controls inside of it. Its cool.

Dim QuestinOptionInsertResult As String = String.Empty
Dim myControl As String
Dim i As Integer
Dim currentTextBox As TextBox
myControl = "_txtOptionText"
Dim ctntplaceHolder As ContentPlaceHolder
ctntplaceHolder =
CType(Page.Master.FindControl("_ContentHolder"), ContentPlaceHolder)
For i = 1 To 5
currentTextBox = ctntplaceHolder.FindControl(myControl
& i)
Dim myCurrentTextBoxValue = currentTextBox.Text
If myCurrentTextBoxValue <> "" Then
Dim QuestionID As Integer =
Convert.ToInt32(GetBL.GetQuestionID())
QuestinOptionInsertResult =
GetBL.InsertQuestionOptions(QuestionID, _

myCurrentTextBoxValue, _

InsertedBY, _

ModifiedBy)
End If
Next i

May 24 '06 #6

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

Similar topics

2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
1
by: Paul M. Frazier, Ph.D. | last post by:
I am writing a user information update page and I populate the form on Page_Load with the current values of the user's name, etc. When I change the text in one of the textbox controls (e.g.,...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
2
by: Axel Dahmen | last post by:
HI, I want to dynamically add controls to a web page from within a common base class. Unfortunately, ASP.NET fails with "System.Web.HttpException: The Controls collection cannot be modified...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
2
by: Alixx Skevington | last post by:
Hi there peeps, I am having a problem have just started to use usercontrols, and I am hitting a problem. I get the error message above, now each control has a table, and 1 asp:textbox...
3
by: Mr Newbie | last post by:
I am messing around with Web User Controls at present and (think) I have discovered the following. 1.) The identifier for the control in the code behind must match the ID for the control on the...
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User control from my WebForm page? I can't move the method...
1
by: Andy B | last post by:
I have this code: protected void EditEventsWizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { //get the values from the DetailsView TextBox StartTime =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
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...

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.