试图在模板字段旁边添加dropdownList

时间:2018-12-08 11:46:50

标签: c# asp.net

尝试在模板字段标题文本(例如“ Diameter(ddlvalues)”)旁边实现下拉菜单。下拉列表将在页面加载时加载值。

<asp:UpdatePanel runat="server">
                    <ContentTemplate>
                        <asp:GridView ID="gvCWeight" runat="server" DataKeyNames="TPD_rowno" AutoGenerateColumns="false" OnRowDeleting="gvCWeight_RowDeleting" OnRowDataBound="gvCWeight_RowDataBound">
                            <Columns>
                                <asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Row No">
                                    <ItemTemplate>
                                        <asp:Label ID="lblCWeightrowno" runat="server" Text='<%# Eval("TPD_rowno") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Diameter"> 
                                    <asp:DropDownList ID="ddlCWtProp" runat="server" Style="border: 0px;"></asp:DropDownList>                                   
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtCWeightDiaMin" runat="server" Rows="1" MaxLength="10" Text='<%# Eval("diaCWeightMin") %>' AutoPostBack="true" OnTextChanged="txtCWeightsizeMin_TextChanged"></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>
 </Columns>
                        </asp:GridView>
                        <asp:Button ID="btnCWeightAddRow" runat="server" OnClick="btnCWeightAddRow_Click" Text="Add Row" />
                    </ContentTemplate>
                </asp:UpdatePanel>

我正在尝试在模板字段旁边添加dropdownList,但显示错误。元素dropdownlist不是已知元素。如果网站中出现编译错误,则可能会发生这种情况。任何想法都可以理解

1 个答案:

答案 0 :(得分:0)

  <Columns>
        <asp:TemplateField>
              <ItemTemplate>
                   ....................
              </ItemTemplate>
              <HeaderTemplate>
                    Full Name
             </HeaderTemplate>
         </asp:TemplateField>
      </Columns>

如果要在HeaderTemplate中下拉菜单,则可以使用它。