C# 在asp.net中调用TemplateField DropDownList-使用FindControl()进行代码隐藏
这就是我如何在GridView中创建我的C# 在asp.net中调用TemplateField DropDownList-使用FindControl()进行代码隐藏,c#,asp.net,code-behind,findcontrol,C#,Asp.net,Code Behind,Findcontrol,这就是我如何在GridView中创建我的DropDownListLehrbeginn。sss <asp:TemplateField HeaderText="Lehrbeginn" SortExpression="lehrbeginn" HeaderStyle-Width="40px"> <EditItemTemplate> <asp:DropDownList ID="DropDownListLehrbeginn" runat=
DropDownListLehrbeginn
。sss
<asp:TemplateField HeaderText="Lehrbeginn" SortExpression="lehrbeginn" HeaderStyle-Width="40px">
<EditItemTemplate>
<asp:DropDownList ID="DropDownListLehrbeginn" runat="server"></asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelLehrbeginn" runat="server" Text='<%# Bind("lehrbeginn") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
不幸的是,它不起作用。如何解决此问题<代码>DropDownListLehrbeginn在代码隐藏中不可用您的代码看起来不错。因为您的下拉列表位于另一个元素中,所以您可能只需要使用如下内容
DropDownList ddlList = (DropDownList)NameOfGridView.FindControl("DropDownListLehrbeginn");
它的可能复制品不是那样工作的…它对我不起作用。dropdownlist仍然为空
DropDownList ddlList = (DropDownList)NameOfGridView.FindControl("DropDownListLehrbeginn");