通常直接在GridView 編輯狀態的時後都是使用TextBox來輸入更新資料
但若希望使用下拉式選單選擇資料可以採取以下的作法
做法如下
初始化DropDownList的資料
並設置選取的DateText及DataValue
<asp:GridView ID="GridView1" runat="server" DataSourceID="EntityDataSource1"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="seqid" >
<Columns>
<asp:TemplateField HeaderText="尺寸" SortExpression="pmid">
<EditItemTemplate>
<asp:DropDownList ID="gvtype" runat="server" DataTextField="Text" DataValueField="Value" SelectedValue='<%# Bind("size") %>' OnInit="DropDownList1_Init" />
</EditItemTemplate>
<ItemTemplate><%# Eval("size")%></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="設定" ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="lbtn1" runat="server" CausesValidation="True" CommandName="Update" Text="更新" />
<asp:LinkButton ID="lbtn2" runat="server" CausesValidation="False" CommandName="Cancel" Text="取消" />
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="EditBtn" runat="server" CausesValidation="False" CommandName="Edit" Text=" 編輯" />
</ItemTemplate>
<ItemStyle Width="70px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
c#.cs:
protected void DropDownList1_Init(object sender, EventArgs e)
{
DropDownList dl = sender as DropDownList;
dl.DataSource = new List<ListItem>()
{
new ListItem(){ Text ="S", Value="0"},
new ListItem(){ Text ="M", Value="1"},
new ListItem(){ Text ="L", Value="2"},
};
}