简体   繁体   English

在行编辑模板中编辑控件

[英]Editing control inside Row Edit Template

Hello, I'm currently trying to load data into one of the RowEditTemplate's controls. 您好,我目前正在尝试将数据加载到RowEditTemplate的控件之一中。

I have a regular ASP.NET DropDownList inside said template. 我说模板里面有一个常规的ASP.NET DropDownList。 This list should be loaded with data from a List, where MyObject has an Id and a Name. 此列表应加载列表中的数据,其中MyObject具有ID和名称。
I've been searching for quite some time now and I don't seem to be able to find a way to get this list from the code behind and load said data. 我已经搜索了很长时间,但似乎无法找到一种方法来从背后的代码中获取此列表并加载所述数据。

Any help is welcome, thank you 欢迎任何帮助,谢谢

Ok, as expected coming from lady luck(?), a little while after asking this I found the answer. 好吧,正如幸运女神(?)所期望的那样,问了一段时间后我找到了答案。

In order to get a control from inside the RowEditingTemplate you first need to get access to the Template in question. 为了从RowEditingTemplate内部获取控件,您首先需要访问有问题的模板。 So, to answer my own question, in order to get my list I did: 因此,为了回答我自己的问题,为了获得我的清单,我做了:

DropDownList ddlMyObjects = (DropDownList)WebDataGrid1.Behaviors.EditingCore.Behaviors.RowEditTemplate.TemplateContainer.FindControl("control_MyObject");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM