Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created textboxes in for loop
C#
                 for (int i = 0; i <= 6; i++)
 {%>
<asp:TextBox ID="tbUcretBilgi" class="form-control"  runat="server"></asp:TextBox>
 }


I want to get values from these textboxes
but how I can, i don't know.

What I have tried:

I didn't try anything because I couldn't find about this
Posted
Updated 19-Aug-16 7:24am
v2

You created all boxes with same id. Since the id is used to retrieve the value, you see only one.

Solution: as you create the boxes, make sure you create a different id for each. Like tbUcretBilgi1, tbUcretBilgi2, tbUcretBilgi3 ...
 
Share this answer
 
Comments
Kaan Öztürk 19-Aug-16 13:42pm    
But when it's repeater. i can do; http://www.codeproject.com/Questions/1119248/Cant-get-checkbox-checked-value-in-repeater-ASP-NE
can't i make without repeater ?
Patrice T 19-Aug-16 13:51pm    
The question is about textbox or checkbox ?
Kaan Öztürk 19-Aug-16 14:05pm    
textbox. checkbox was a sample.
Patrice T 19-Aug-16 14:07pm    
They are different beasts, please choose what you talk about.
Kaan Öztürk 19-Aug-16 17:43pm    
checkbox is an object and textbox too. if i can check checkbox value, i can for textbox too. Anyway, I solved this problem with panel
i created a panel on html. My texboxes in there and;
int i =0;
foreach (TextBox tbUcretBilgi in Panel1.Controls.OfType<textbox>())
{
xArray[i]=tbUcretBilgi.Text;
i++
}
i can catch values with this. for example; i have 6 texboxes and i'm filling,
tb1.text: Sample1
tb2: sample2
3: sample3
4: sample4
5: null
6: null
tbUcretBilgi.text returned one value; "Sample1,Sample2,Sample3,Sample4,,,"
So,
xArray[0]="Sample1,Sample2,Sample3,Sample4,,,"
xArray[1]=null
xArray[2]=null
...
how can i fill properly? Do you have an idea ? :) thanks..
I guess there's not a solution for this if the ID is the same to the 6 textboxes you have created!

Do you want to get the values in code behind, right?
 
Share this answer
 
Comments
Kaan Öztürk 19-Aug-16 17:52pm    
yes. i solved with panel.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900