如何根据表中增加的公司数量在Web表单中动态创建Gridview [英] How I Can Create Gridview Dynamically In Web Form Acccording To Number Of Companyid In Increase In Table

查看:104
本文介绍了如何根据表中增加的公司数量在Web表单中动态创建Gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何根据条件显示数据分离Gridview,

我的意思是在表格中我有价值



< pre lang =sql> - ----------------- -------------------------------------------
CompanyID | BranchID | EmployeeID | EmployeeName
- ------------------- -----------------------------------------
< span class =code-digit> 1 | 1 | 1 | Arvind |
1 | 1 | 2 | Ajay |
1 | 3 | 3 | Sonu |
1 | 2 | 4 | Vinod |
1 | 1 | 5 |塔伦|
1 | 2 | 6 | Uddhav |
2 | 2 | 7 |拉维|
2 | 1 | 8 | Govinda |
2 | 2 | 9 |罗宾|
2 | 2 | 10 | Anand |





这里CompanyID是1和2然后两个GridView必须显示在WebForm上



如何根据CompanyID获得此数据的输出,

例如dinstinct(CompanyID)为1,2,3及更多



如果CompanyID的数量增加了我如何增加Gridview的数量?

解决方案

  var  distinctCompanyIds = datatable.AsEnumerable()
.Select(s = > new {
id = s.Field< string>( CompanyId),
})
.Distinct()。ToList();



现在计算 distinctCompanyIds 并动态创建该数量的 GridViews

How i can separate Gridview according to condition display data,
what i means is that in table i have value like

--------------------------------------------------------------
CompanyID | BranchID | EmployeeID | EmployeeName
-------------------------------------------------------------- 
  1       |   1      |     1      |   Arvind     |
  1       |   1      |     2      |   Ajay       |
  1       |   3      |     3      |   Sonu       |
  1       |   2      |     4      |   Vinod      |
  1       |   1      |     5      |   Tarun      |
  1       |   2      |     6      |   Uddhav     |
  2       |   2      |     7      |   Ravi       |
  2       |   1      |     8      |   Govinda    |
  2       |   2      |     9      |   Robin      |
  2       |   2      |    10      |   Anand      |



here CompanyID is 1 and 2 then two GridView must display on WebForm

how i can get output of this data according to CompanyID,
e.g dinstinct(CompanyID) is 1 , 2 , 3 and more

if Number of CompanyID increases how i can increase the number of Gridview ??

解决方案

var distinctCompanyIds = datatable.AsEnumerable()
                         .Select(s=> new {
                                          id = s.Field<string>("CompanyId"),
                          })
                         .Distinct().ToList();


Now count the distinctCompanyIds and dynamically create that number of GridViews.


这篇关于如何根据表中增加的公司数量在Web表单中动态创建Gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆