Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need HTML label text in c# asp.net string variable using the for loop how to achieve this

What I have tried:

<label for='radiobutton' id='lbl'>Some Text...</label>
for(int i = 1; i<=dt.Rows.Count; i++)
{
string label = hdnLabel.Value// <-- Here i required the label text value
}

I have used hidden field and only getting the last text but not the first to till count ends.
Posted
Updated 10-Jan-19 19:08pm
Comments
RmcbainTheThird 2-Jan-19 7:36am    
Can you show us the markup for the label?
Richard MacCutchan 2-Jan-19 7:50am    
Your code only ever gets the text from hdnLabel, so what is the reason for the loop?
Prifti Constantine 2-Jan-19 8:14am    
With this code there is no reason for a loop. if you want to iterate through the controls inside the page then that's another story and you will need to cast the Control to the appropriate inner type.Maybe some more Code and maybe a better understanding of the problem or a better explanation of it might help.
Member 8583441 2-Jan-19 23:30pm    
sorry for the late reply, if for loop is not required then can it be used with request.form to get the text of HTML Label i.e.,
<label>Some Text...</label>
If i require this some text can i get from request.form
Member 8583441 2-Jan-19 23:32pm    
why i am using for loop is this label is having lots of records from the database display to retrieve that data

<asp:label id="LblGetValue" Text="Here is some text" runat="server"/>
for(int i = 1; i<=dt.Rows.Count; i++)

{
	string label = LblGetValue.value
}
 
Share this answer
 
System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.Convert.ToDateTime(String value) at Operator_RegistrationForm.SAVENONCSC() at Operator_RegistrationForm.saveButton_Click(Object sender, EventArgs e
 
Share this answer
 
Comments
Richard Deeming 11-Jan-19 9:55am    
Not even a vague attempt to answer the question!

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