【问题标题】:How to Put Textbox and Dropdownlist in Gridview for Editing?如何将文本框和下拉列表放在 Gridview 中进行编辑?
【发布时间】:2017-03-25 04:04:04
【问题描述】:

对不起。我真的很陌生,但我真的很努力。所以我真的需要关于如何在 gridview 中放置一个文本框和一个下拉列表进行编辑的帮助。

这是我的 GridView 代码

 <div id="id_tm1" runat="server" class="grid" style="border: 1px solid black; overflow: scroll;
                            width: 94%; height: 103px" visible="true">
                            <asp:GridView ID="gvGroup" runat="server" AllowPaging="true" AllowSorting="True"
                                AutoGenerateColumns="False" BorderColor="Silver" BorderWidth="1px" Height="77px"
                                Width="98%">
                                <RowStyle Font-Names="Arial" Font-Size="9pt" HorizontalAlign="Center" />
                                <Columns>
                                    <asp:BoundField DataField="JOBTITLE" HeaderStyle-BackColor="#666666" HeaderText="Job Title"
                                        ItemStyle-Height="10px" ItemStyle-Width="50px">

                                        <HeaderStyle BackColor="#666666" />
                                        <ItemStyle Width="50px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="BUSINESS_UNIT" HeaderStyle-BackColor="#666666" HeaderText="Business Unit"
                                        ItemStyle-Height="10px" ItemStyle-Width="50px">
                                        <HeaderStyle BackColor="#666666" />
                                        <ItemStyle Width="50px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="DIVISION" HeaderStyle-BackColor="#666666" HeaderText="Division"
                                        ItemStyle-Height="10px" ItemStyle-Width="50px">
                                        <HeaderStyle BackColor="#666666" />
                                        <ItemStyle Width="50px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="SUB_DIVISION" HeaderStyle-BackColor="#666666" HeaderText="Sub-Division"
                                        ItemStyle-Height="10px" ItemStyle-Width="50px">
                                        <HeaderStyle BackColor="#666666" />
                                        <ItemStyle Width="50px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="CLASSIFICATION" HeaderStyle-BackColor="#666666" HeaderText="Classification"
                                        ItemStyle-Height="10px" ItemStyle-Width="50px">
                                        <HeaderStyle BackColor="#666666" />
                                        <ItemStyle Width="50px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="SUB_CLASSIFICATION" HeaderStyle-BackColor="#666666" HeaderText="Sub-Classification"
                                        ItemStyle-Height="10px" ItemStyle-Width="50px">
                                        <HeaderStyle BackColor="#666666" />
                                        <ItemStyle Width="50px" />
                                    </asp:BoundField>
                                </Columns>
                                <PagerStyle Font-Size="9pt" HorizontalAlign="Right" />
                                <EmptyDataTemplate>
                                    <div style="width: 100%; font-size: 10pt; text-align: center; color: Red;">
                                        No record found.
                                    </div>
                                </EmptyDataTemplate>
                                <HeaderStyle BackColor="DarkGray" Font-Bold="True" Font-Names="Arial" Font-Size="9pt"
                                    ForeColor="White" HorizontalAlign="Center" />
                                <AlternatingRowStyle BackColor="Gainsboro" />
                            </asp:GridView>
                        </div>

我尝试输入 &lt;asp:TemplateField&gt;&lt;asp:DropDownList&gt;,但出现错误“类型 'System.Web.UI.WebControls.BoundField' 没有名为 'TemplateField' 或 'DropDownList' 的公共属性”

当我单击 gridview 项目列表中的编辑按钮以便能够编辑它Output 时,应该会出现文本框和下拉列表。非常感谢。

【问题讨论】:

标签: html asp.net vb.net gridview


【解决方案1】:

BoundField标签内不允许有Template Field标签,应该是单独标签的例子。

<asp:BoundField DataField="JOBTITLE" HeaderStyle-BackColor="#666666"   HeaderText="Job Title"ItemStyle-Height="10px" ItemStyle-Width="50px">
                                    <HeaderStyle BackColor="#666666" />
                                    <ItemStyle Width="50px" />
 </asp:BoundField>

 <asp:TemplateField HeaderText = "Column Header" ItemStyle-Width="95px" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
 <asp:DropDownList ID="yourDrodDown" runat="server">  
         <asp:ListItem Selected="True">Item 1 </asp:ListItem>
         <asp:ListItem>Item 2</asp:ListItem>
       <asp:ListItem>Item 3</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>

</asp:TemplateField>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    • 2017-11-26
    • 2011-11-21
    • 2011-08-31
    • 2015-10-22
    • 1970-01-01
    相关资源
    最近更新 更多