Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How i can separate Gridview according to condition display data,
what i means is that in table i have value like

SQL
--------------------------------------------------------------
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 ??
Posted

1 solution

C#
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900