GridView, Repeater进阶用法

1. Gridview中当设置自动生成列时对列中字段使用 html代码显示

 绑定时设置

 2.  选择

    

//前台
AutoGenerateSelectButton="true" 
//后台 
 if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#999999'"); //鼠标滑过变色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");//鼠标划出变回原色
                // e.Row.Attributes.Add("onclick", e.Row.ClientID.ToString() + ".checked=true;selectx(this)");
                e.Row.Attributes.Add("onclick", "__doPostBack('GvSource','Select$" + e.Row.RowIndex + "')");
            }

 二、 Repeater用法

前台绑定数据源: 

<td>
<%# DataBinder.Eval(Container.DataItem, "FATHERNAME")%>
</td>

前台调用后台方法,处理数据源后显示:

<td>
<%#HidNum(Convert.ToString(Eval("MOTHERPHONENUM"))) %>
</td>

原文地址:https://www.cnblogs.com/crazylight/p/3214793.html