I've a linq something like below.
Dim tblL1 = From tb In tblData _
Group tb By Company = tb.Company, Plant = tb.Plant, _
MaterialType = tb.MaterialType, MaterialGroup = tb.MaterialGroup _
Select Company, Plant, MaterialType, _
Value = FormatCurrency(Math.Round(Group.Sum(Function(tb) tb.PCPValue), 0), 0), _
NoOfParcels = Math.Round(Group.Sum(Function(tb) tb.NO_OF_PARCEL), 0) _
Order By Company,Plant,MaterialType
gvData.DataSource = tblL1.ToList
Everything is working properly.
The thing is the sort order will be selected by user.
I've given 3 combos from which user can select the sort order, based on which the o/p should be. So I've declared a variable like this.
Dim strOrder As String = ""
If cboSortOrder1 <> "" Then
strOrder &= cboSortOrder1.SelectedValue & ","
If strOrder.EndsWith(",") Then
strOrder = strOrder.Remove(strOrder.LastIndexOf(","))
And if I replase the order by values with this strOrder, Then no errors but its not getting sorted as desired. I've paging in my gridview. so tbl1.tolist is necessary. Or alternatively if tolist has to be removed then what shold I do?
Its not possible to write the query with each and every combination, B'cas here I've shown only 3 columns. In reality I've more than 10 columns.
How to achieve this?
Thanks in advance...