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

C# Find Text Boxes Grab Data

karenRoss
P: 27
Hi!

Okay, here's the issue:

I have a nested repeater with this:
<td width="125px"><input type="text" name="M<%# DataBinder.Eval(Container.DataItem, "combos_id") %>" size="10" maxlength="10"></td>
<td width="350px"><input type="text" name="C<%# DataBinder.Eval(Container.DataItem, "combos_id") %>" size="50" maxlength="100"></td>

I need to search the page, find all the text boxes and get their values. However, I don't know anything about the ID other than it starts with a C or an M. I can't get a count from my initial data, so I query again to get the number of text boxes possible.

Even with a loop I cannot seem to actually "find" the objects. Any thoughts on any way to do this at all? foreach?
Aug 23 '07 #1
Share this Question
Share on Google+
2 Replies


Shashi Sadasivan
Expert 100+
P: 1,435
Hi!

Okay, here's the issue:

I have a nested repeater with this:
<td width="125px"><input type="text" name="M<%# DataBinder.Eval(Container.DataItem, "combos_id") %>" size="10" maxlength="10"></td>
<td width="350px"><input type="text" name="C<%# DataBinder.Eval(Container.DataItem, "combos_id") %>" size="50" maxlength="100"></td>

I need to search the page, find all the text boxes and get their values. However, I don't know anything about the ID other than it starts with a C or an M. I can't get a count from my initial data, so I query again to get the number of text boxes possible.

Even with a loop I cannot seem to actually "find" the objects. Any thoughts on any way to do this at all? foreach?
Hi karen,
what you have to do is get a list of all controls by this.controls, and check if they are a input type (if you can use asp .net controls it would be easier i suppose)

also refer to this site:
http://aspnet.4guysfromrolla.com/art...81402-1.2.aspx
Aug 24 '07 #2

P: 9
Hi!

Okay, here's the issue:

I have a nested repeater with this:
<td width="125px"><input type="text" name="M<%# DataBinder.Eval(Container.DataItem, "combos_id") %>" size="10" maxlength="10"></td>
<td width="350px"><input type="text" name="C<%# DataBinder.Eval(Container.DataItem, "combos_id") %>" size="50" maxlength="100"></td>

I need to search the page, find all the text boxes and get their values. However, I don't know anything about the ID other than it starts with a C or an M. I can't get a count from my initial data, so I query again to get the number of text boxes possible.

Even with a loop I cannot seem to actually "find" the objects. Any thoughts on any way to do this at all? foreach?
HI KAREN,
to get all the controls within a form, u can use

Controls oFormControls=this.Controls;
it returns all the controls on the form. but it better if u put all the textbox in groupbox or panel. then it'll iterate throw few controls.

//this code iterate throw all controls on the form
foreach (Control ctl in this.Controls)
{
if(ctl.GetType().Name== "TextBox")
{
if(ctl.Name="txtName")
string sName=ctl.Text;
}
}

//this code iterate throw all controls on the grpTextBox of the form

foreach (Control ctl in this.grpTextBox.Controls)
{
if(ctl.GetType().Name== "TextBox")
{
if(ctl.Name="txtName")
string sName=ctl.Text;
//do something
}
}


i think it resolve ur problem. if not or u want to know more about it, mail me to
[email removed]

!!! SHIPON !!!
Aug 24 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.