DropDownList的insideTemplateField是不是从code-访问的背后 [英] DropDownList insideTemplateField is not accessible from code-behind

查看:173
本文介绍了DropDownList的insideTemplateField是不是从code-访问的背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对在网页中放置datailsview,给它一个数据源更新我的表,

我已经介绍了在有界控制的中间一个DropDownList,并希望它填补
根据我给定的指令,但DropDownList的是不是在$ C $通过ID访问C-背后,例如:

 < ASP:的TemplateField>
    <&ItemTemplate中GT;
        < ASP:DropDownList的ID =drpdownlist的DataSourceID =deptsourceWIDTH =150像素DataTextField =DEPTNAMEDataValueField =DEPTID=服务器/>
    < / ItemTemplate中>
< / ASP:的TemplateField>


解决方案

首先,你需要使用的FindControl()法行数据绑定为abatishchev后述。此外,您还需要记住,这不会是可能的,直到有其实在网格中的某些行。但你还需要记住,你不会得到只是一个的DropDownList ,而是会出现有一个的DropDownList 每个排在你的 GridView控件

i am updating my table by placing datailsview in the webpage and giving it a datasource,

i have introduced a dropdownlist in the middle of bounded control and want it to be filled according to my given instruction, but the DropDownList is not accessible via ID in code-behind, e.g.:

<asp:TemplateField>
    <ItemTemplate>
        <asp:DropDownList ID="drpdownlist" DataSourceID="deptsource" Width="150px" DataTextField="deptname" DataValueField="deptid" runat="server" />
    </ItemTemplate>
</asp:TemplateField>

解决方案

First you need to use the FindControl() method after rows are databound as abatishchev mentioned. Also, you need to remember that this wont be possible until there are in fact some rows in the grid. But you need to also remember that you will not get just one DropDownList, but instead there will be one DropDownList for each row in your GridView.

这篇关于DropDownList的insideTemplateField是不是从code-访问的背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆