datatable.select("dintinct columnName");
-
i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks
much clearly explanation would help our experts to give accurate answer.... :rolleyes:
Padmanabhan My Articles[^]
-
much clearly explanation would help our experts to give accurate answer.... :rolleyes:
Padmanabhan My Articles[^]
i have a datatable "TableA" with columns CompanyName EmployeeName EmployeeSalary CompanyName gets repeated in the datatable i want company name in some other datatable say "TableB" and company name should be only once in the column. i want to run query on TableA.Select("Query"); to get unique CompanyName and add these rows to TableB. All i know but wt i nyd to know is wt shd be d query for it. i tries select distinct CompanyName but it thorows an exception
-
i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks
-
i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks
If you are using .net framework 3.5 then use LINQ as follows
var query = (from c in dt.AsEnumerable() select new { FirstName = c.Field<string>("FirstName"), LastName = c.Field<string>("LastName") }).Distinct() ;
It will give you distinct values.
himanshu
-
If you are using .net framework 3.5 then use LINQ as follows
var query = (from c in dt.AsEnumerable() select new { FirstName = c.Field<string>("FirstName"), LastName = c.Field<string>("LastName") }).Distinct() ;
It will give you distinct values.
himanshu
-
Hi Aijaz, But if you are working on framework 3.5 then you can use the code i have posted above. If not then you might be need to create dataview and then filter rows from there.
himanshu
-
Hi Aijaz, But if you are working on framework 3.5 then you can use the code i have posted above. If not then you might be need to create dataview and then filter rows from there.
himanshu
-
i want to get distinct values of a column in datatable in asp.net. is it possible and how? thanks
You can try hashtables for doing this. But the best way is to change the display at runtime by merging the cells in gridview. You can have a look at this: http://forums.asp.net/p/1053747/1494505.aspx[^] Regards, Kaushal Arora Mark as Answer if it Solved Your Problem.