要求:
N道题目,每页10题前台:
1、在Repeater中添加下拉框,所以每行都有一个下拉框,名字为DropDownList1
2、在repeater外有一个按钮Button1,提交页面后台:
1、Not IsPostBack 时间中绑定Repeater数据,取出前10题(e.g. 1~10题)希望Button1_Click事件中
1、获取DropDownList1(1~10题)的答案,插入数据库
2、读取后10题(11~20题),绑定Repeater现在问题是无法再button1_click事件中读取提交的值,读出来为空,我想是因为页面的Repeater中的DropDownlist还没有显示出来。请问大侠们,如何解决这个问题,应该是什么思路或者用什么事件比较合理。谢谢了!
N道题目,每页10题前台:
1、在Repeater中添加下拉框,所以每行都有一个下拉框,名字为DropDownList1
2、在repeater外有一个按钮Button1,提交页面后台:
1、Not IsPostBack 时间中绑定Repeater数据,取出前10题(e.g. 1~10题)希望Button1_Click事件中
1、获取DropDownList1(1~10题)的答案,插入数据库
2、读取后10题(11~20题),绑定Repeater现在问题是无法再button1_click事件中读取提交的值,读出来为空,我想是因为页面的Repeater中的DropDownlist还没有显示出来。请问大侠们,如何解决这个问题,应该是什么思路或者用什么事件比较合理。谢谢了!
请问有没有其他好办法。谢谢
但是.net中repeater怎么读取form中的控件值啊,如果可以这就可以解决问题了:)
查看页面源文件 select的ClientID: Request.Form["ClientID"]
{ BindData();}
<asp:repeater id="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound">
<itemtemplate>
<div>
<asp:dropdownlist id="ddl" autopostback="true" onselectedindexchanged="myDrop_SelectedIndexChanged" runat="server"> </asp:dropdownlist>
</div>
</itemtemplate>
</asp:repeater> protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
{
DropDownList myDrop = e.Item.FindControl("ddl") as DropDownList;
}
} protected void myDrop_SelectedIndexChanged(object sender,EventArgs e)
{
Response.Write(((DropDownList)sender).SelectedIndex.ToString());
}
{
DropDownList ddl = rptItem.FindControl("ddl") as DropDownList;
}
页面提交后,当dropdownlist都加载完成后可以通过这个方式获得值,但是如何在加载前获得还是不大清楚。
ItemDataBound该如何使用啊?查询了一些资料,还是不清楚。