Repeater绑定事件ItemDataBound中获取数据库中数据

时间:2022-07-20 15:37:20

protected void rp1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

{
                        //DataBinder.Eval(e.Item.DataItem, "数据库字段")
                      //int i = Convert.ToInt32(Databinder.Eval(e.Item.DataItem,"ID"));
                          Response.Write(Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ID")+"<br>"));

}
        }