前台:
<asp:TemplateField HeaderText="資質">
<ItemTemplate>
<asp:Label ID="lblAptitude" runat="server" Text='<%#Eval("Aptitude") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lbl2" runat="server" Text='<%#Eval("Aptitude") %>' style="display:none;"></asp:Label>
<asp:DropDownList ID="ddlAptitude" runat="server">
<asp:ListItem Value="合格" Text="合格"></asp:ListItem>
<asp:ListItem Value="儲備" Text="儲備"></asp:ListItem>
<asp:ListItem Value="潛在" Text="潛在"></asp:ListItem>
<asp:ListItem Value="不合格" Text="不合格"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
後台:
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex == gvList.EditIndex)
{
//編輯時下拉菜單默認值
ddlAptitude.Text = ((Label)e.Row.FindControl("lbl2")).Text;
}
}