如何获取为 ASP.NET 中的 BoundField 生成的控件的 ClientID?

发布于 2024-08-19 10:18:37 字数 332 浏览 4 评论 0原文

我有一个包含 BoundFields 的表单,我需要获取与表单中每个 BoundField 关联的控件的 ClientID。 我该怎么做呢?

UPD:我没有控制 ID。我所拥有的只是绑定字段,不能有 id。

UPD2:我正在尝试编写这样的代码:

public IDictionary<BoundField, string> GetCliendIDs(FormView formView)
{
    // How to find Client IDs for controls which were created for BoundFields
}

I have a form with BoundFields in it and I need to get ClientID(s) for control(s) associated with each BoundField I have in the form.
How can I do it?

UPD: I do not have control id. All I have is bound field which can not have an id.

UPD2: I'm trying to write a code like this:

public IDictionary<BoundField, string> GetCliendIDs(FormView formView)
{
    // How to find Client IDs for controls which were created for BoundFields
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉世弥音 2024-08-26 10:18:37

试试这个:

yourForm.FindControl("yourControl").ClientID.ToString();

其中“yourcontrol”是表单中控件的 id。您可以通过在源代码模式下打开aspx页面并查看该控件的ID值来找到该值。

此外,如果您知道绑定字段在表单控件中的位置,则可以访问它们,例如:

yourform.Controls[0].ClientID //first control 
yourform.Controls[1].ClientID //second control 

Try this:

yourForm.FindControl("yourControl").ClientID.ToString();

Where "yourcontrol" is the id of the control in your form. You can find this value by opening the aspx page in source mode and look at the ID value of the control.

Also, you could access the boundfield if you know the location of them in the form control, example:

yourform.Controls[0].ClientID //first control 
yourform.Controls[1].ClientID //second control 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文