repeater中radiobuttonlist如何绑定数据,请求完整代码块

2024-11-30 23:42:30
推荐回答(1个)
回答(1):

事件错误,应该在ItemDataBound事件中处理,类似如下

onitemdatabound="Repeater1_ItemDataBound">



<%#Eval("M_Addate", "{0:yyyy-MM-dd}")%>



<%#Eval("M_Title")%>




AutoPostBack="true">






protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
RadioButtonList rbl1 = (RadioButtonList)e.Item.FindControl("RadioButtonList1 ");
rbl1.DataSource = this.Repeater1.DataSource;
rbl1.DataTextField = "M_Bit";
rbl1.DataValueField = "M_ID";
rbl1.DataBind();
}
}