關於Repeater中使用DorpWownList的問題
前臺:
<asp:Repeater ID="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand" onitemdatabound="Repeater1_ItemDataBound">
<asp:DropDownList ID="Curriculum1" runat="server">
<asp:ListItem>大專</asp:ListItem>
<asp:ListItem>本科</asp:ListItem>
<asp:ListItem>博士</asp:ListItem>
<asp:ListItem>碩士</asp:ListItem>
</asp:DropDownList>
</asp:Repeater>
後臺
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//Response.Write();
DataRowView drv = (DataRowView)e.Item.DataItem;
DropDownList UsCurr = e.Item.FindControl("Curriculum1") as DropDownList;
string UsCurrVal= drv["userCurriculum"].ToString();
UsCurr.SelectedValue = UsCurrVal;
//string haveimg = drv["userCurriculum"].ToString();
//Response.Write(haveimg);
}
說明:在Repeater的ItemDataBound事件中進行獲取值
謹此獻給苦苦查詢資料的我,希望能幫到後來人。
謹此獻給苦苦查詢資料的我,希望能幫到後來人。