GridView根据不同用户显示不同行数,循环读取的时候怎么办
用户表 内容表
Id | name | Depaer || IDepartID | DepaerName | DepaerOpp ||
其中 Depaer=IDepartID
我的方法
protected void gvDepartMain_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow)//判断行类型 { string gvId = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();//得到部门id DepartInfo ev = DepartManager.GetDepartByID(gvId); UserInfo user = (UserInfo)Session["CurrentUser"]; string userdepar=ev.IDepartID.Substring(0, 2); if (userdepar ==user.Depaer) { e.Row.Cells[0].Text = ev.VcDepartName; e.Row.Cells[1].Text=ev.DepaerOpp } else { e.Row.Visible = false; } } }