Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I want to fetch the name(Text) of the controls stored in control class and I have to assign it to the checkbox list item.

Here is my sample code

for (int i = 0; i<sdtable1.rows.count;> {
System.Web.UI.Control ctr = SDTable1.Rows[i].Cells[0].Controls[i];
StudentDetailsChecklist.Items.Add(ctr.ID);
}

SDTable is my Html table, I want to fetch the control names not Id.

If I use the above code it fetches the ID of the controls, I need to fetch the name of the control.

Thanks
Rajesh
Posted
Updated 30-Sep-13 21:09pm
v2

1 solution

You can use
Control.GetType().Name which fetches you the name of the control.

Hope this helps
 
Share this answer
 
v2
Comments
rajeshkool 1-Oct-13 5:24am    
@JoCodes, Thanks for your reply . But the "Control.GetType().Name" fetching the type of control like label,dropdownlist,textbox,etc. But,I need to fetch the text of that label.
JoCodes 1-Oct-13 6:20am    
Yes, I thought that was you were looking since you asked "I need to fetch the name of the control". You need somethin like the value of the control holds? StudentDetailsChecklist.Items.Add(ctr.ID.Text);???
rajeshkool 1-Oct-13 7:23am    
@JoCodes. I like to fetch the text property of the control.

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