将存储在控件类中的动态创建的控件的名称分配给checkboxlist项 [英] Assign the name of dynamically created controls stored in control class to the checkboxlist items
问题描述
我想获取控件类中存储的控件的名称(Text),我必须将它分配给复选框列表项。
这是我的示例代码
for(int i = 0; i< sdtable1.rows.count ;> {
System.Web.UI.Control ctr = SDTable1.Rows [i] .Cells [0] .Controls [i];
StudentDetailsChecklist.Items。添加(ctr.ID);
}
SDTable是我的Html表,我想获取控件名称而不是Id。
如果我使用上面的代码它会获取控件的ID,我需要获取控件的名称。
谢谢
Rajesh
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
推荐答案
你可以使用
Control.GetType()。名字哪个获取控件的名称。
希望这有帮助
You can use
Control.GetType().Name which fetches you the name of the control.
Hope this helps
这篇关于将存储在控件类中的动态创建的控件的名称分配给checkboxlist项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!