<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="客户ID"
DataSourceID="AccessDataSource1">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="客户ID" HeaderText="客户ID" ReadOnly="True" SortExpression="客户ID" />
<asp:BoundField DataField="公司名称" HeaderText="公司名称" SortExpression="公司名称" />
<asp:TemplateField HeaderText="城市" SortExpression="城市">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDataSource1"
DataTextField="城市" DataValueField="城市" SelectedValue='<%# Bind("城市") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("城市") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Northwind.mdb"
SelectCommand="SELECT [客户ID], [公司名称], [城市] FROM [客户]" UpdateCommand="UPDATE [客户] SET [公司名称] = ?, [城市] = ? WHERE [客户ID] = ?">
<UpdateParameters>
<asp:Parameter Name="公司名称" Type="String" />
<asp:Parameter Name="城市" Type="String" />
<asp:Parameter Name="客户ID" Type="String" />
</UpdateParameters>
</asp:AccessDataSource>
将DropDownList放入GridView中
最新推荐文章于 2016-07-28 15:59:00 发布