关于Repeater中使用DorpWownList的问题

关于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事件中进行获取值
谨此献给苦苦查找资料的我,希望能帮到后来人。
posted @ 2015-12-24 16:19  fasin  阅读(229)  评论(0)    收藏  举报