使用下拉列表在Gridview中编辑单个列

时间:2015-10-28 20:10:21

标签: asp.net vb.net gridview

我想在单个列中添加一个下拉列表控件。下拉列表值将在表示层上声明

enter image description here

我只想在User_Status中设置一个保管箱,以便我可以查看状态,当我点击保存按钮时,更改会保存到数据库

<asp:Content ID="Content5" ContentPlaceHolderID="MainContent" Runat="Server">
      <asp:GridView  ID="GridView1" DataSourceID="SqlDataSource1"   runat="server"   BackColor="White" BorderColor="#808080" AutoGenerateColumns="True" AutoGenerateEditButton ="true"
              CellPadding="4" ForeColor="Black" GridLines="Vertical"  
            AllowSorting="True" AllowPaging="True" PageSize="4"   >
      </asp:GridView>

1 个答案:

答案 0 :(得分:0)

这里使用模板字段

            <asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="false" DataKeyNames="Id" OnRowDataBound="grdView4_OnRowDataBound" CssClass="Grid table table-hover table-bordered" OnSelectedIndexChanged="GridView4_SelectedIndexChanged">
                 <Columns>
                   <asp:TemplateField ItemStyle-Width="20px">
                     <ItemTemplate>
                        <asp:DropDownlist runat="server">
                     </ItemTemplate>
                    </asp:TemplateField>
                  </Columns>
            </asp:GridView>