[置顶] gridview中嵌套gridview(并实现子gridview的数据绑定),页面传值,加密,数据绑定

时间:2021-02-16 15:58:32

先来张效果图

[置顶]        gridview中嵌套gridview(并实现子gridview的数据绑定),页面传值,加密,数据绑定

gridview 中嵌套gridview的原理是这样的,在父gridview中建一个摸板列,然后再模版列当中在放入子gridview,然后再父gridview的OnRowDataBound事件中在对子gridview进行数据绑定,首先要获取子gridview的控制权,然后进行数据绑定

 protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
utils util=new utils();
HiddenField hf_year=(HiddenField)e.Row.FindControl("hf_year");
if (hf_year != null)
{
string path = hf_year.Value.ToString();
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gvMajor = (GridView)e.Row.FindControl("gvMajor");
gvMajor.DataSource = util.GetMajorName(path);
gvMajor.DataBind(); }
}