我有一个包含BoundFields的表单,我需要获取ClientID(s)以获取与表单中的每个BoundField相关联的控件。 我该怎么办?
UPD:我没有控制ID。我所有的都是绑定字段,不能有id。
UPD2:我正在尝试编写这样的代码:
public IDictionary<BoundField, string> GetCliendIDs(FormView formView)
{
// How to find Client IDs for controls which were created for BoundFields
}
答案 0 :(得分:2)
试试这个:
yourForm.FindControl("yourControl").ClientID.ToString();
“yourcontrol”是表单中控件的id。您可以通过在源模式下打开aspx页面并查看控件的ID值来找到此值。
另外,如果你知道它们在表单控件中的位置,你可以访问boundfield,例如:
yourform.Controls[0].ClientID //first control
yourform.Controls[1].ClientID //second control