Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在asp.net中调用TemplateField DropDownList-使用FindControl()进行代码隐藏_C#_Asp.net_Code Behind_Findcontrol - Fatal编程技术网

C# 在asp.net中调用TemplateField DropDownList-使用FindControl()进行代码隐藏

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=

这就是我如何在GridView中创建我的
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");