Repeater,ItemDataBound事件,获取绑定列的值,给指定列添加js方法

时间:2022-04-04 11:02:34

protected void rp_bf_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string str_if_end = DataBinder.Eval(e.Item.DataItem, "if_end").ToString();
if (str_if_end == "1") //drv.Row.ItemArray[0]就是你要取的数据源中的第0列了,你的Uname在第几列就自己写了。。。
{
HtmlInputCheckBox cb = e.Item.FindControl("cbo_select") as HtmlInputCheckBox;
cb.Disabled = true;
}
}
}

//给指定列添加js方法

protected void rp_bf_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
string Point_ID = DataBinder.Eval(e.Item.DataItem, "ID").ToString();//这是数据库的字段
HtmlInputCheckBox cb = e.Item.FindControl("cbo_select") as HtmlInputCheckBox;
cb.Attributes.Add("onclick", "if_upload("+"'" + Point_ID + "'"+")");
}
}