C# - Sort By IsTop Ascending Meanwhile Then By JobId Descending
Mar 17, 2011
I want to sort by IsTop ascending, meanwhile then by jobId descending
query = query.OrderBy(p => p.IsTop).ThenOrderByDescending(p => p.JobId);
how to do it? I know the reverse
query = query.OrderByDescending(p => p.IsTop).ThenBy(p=>p.JobId)
syntax works, but not what i want What i want is actually whatever situation IsToped Item will be at top!
View 2 Replies
Similar Messages:
May 5, 2010
I have a button that I would like to click and will put my Listview list in Descending order. However; when I click on the button nothing happens.
[code].....
View 12 Replies
Apr 28, 2013
I have a datatable,columns are(User_id,Name,Address,DOB)
values like(12,abc,delhi,22/2/2000)
(14,pqr,mumbai,13/3/1989)
(8,klm,banglore,17/5/2001)
(9,asd,pune,12/9/1999)
Now I want to sort these rows on DOB in descending order..how can i do so?
View 1 Replies
Oct 12, 2010
In my table I have a varchar type column, the values like..
sale_date
04/23/2010
02/03/2010
12/24/2010
I need to retrieve the records in both ascending and descending order. Problem is now it is a varchar type if I use order by o/p like
02/03/2010
04/23/2010
12/24/2010
I tried with convert(DATETIME,sale_date) but no use.
View 4 Replies
Feb 18, 2014
How to sorting(ascending and descending ) the gridview when i click the header text on gridview in asp.net
View 1 Replies
Aug 16, 2010
how to sort a datatable (dataview) so that the second column is ascending but nulls are last.
I'm trying to do the following Date1 ASC, DATE2 ASC (but if DATE2 is null it is last in this Date1 group)
Note: Date1 can never be null so a Date2 that is null should still be grouped in with its Date1.
View 4 Replies
Apr 16, 2010
How to sort the dataset Values in Descending order , I have Followed the following way
decimal Length = 94;
decimal Width = 7;
decimal Height = 13;
DataTable dtCarton = new DataTable();
[Code]....
View 6 Replies
Oct 22, 2010
How do I sort a data table based on a particular column which has integer values in ascending order?
I wrote this:
'Sort the datatable based on sequence id leadtable.DefaultView.Sort ="Id" But it doesnt seem to work Datatble is defined as:
[Code]....
View 9 Replies
Jun 3, 2010
I have a simple dynamic gridview with following code -
GV = new GridView();
View 3 Replies
Mar 7, 2010
Actually i want to ask which is the best for sorting in Asp.Net is it DataView.Sort Method or List<Object>.Sort() method.
View 1 Replies
Apr 20, 2010
I'm looking for a way to sort the rows of a datatable without setting the DefaultView.Sort to a specific column. I have a datatable in session that users can add records to. I want them to be able to sort the data by clicking on a button. But new records added after that need to show up at the bottom of the list until the sort button is clicked again.
View 2 Replies
Mar 21, 2011
gridview is always Ascending?
View 5 Replies
Oct 7, 2010
Ascending order based on the Date and month?
[Code]....
View 2 Replies
Nov 16, 2010
Can anybody provide me exact answer of this how to insert checkbox checked value to textbox in ascending order ?
Means if i check checkbox1 and checkbox3 then output in textbox ia 1,2
and if i check checkbox3 then checkbox1 then also output in textbox would be 1,2
I have asked this question ... previously but haven't found any exact working answer ...
Remember ,,, i have to use with 500+ checkboxes .... in asp.net(VB)
View 3 Replies
May 7, 2015
How can i make a gridview always started ascending, depending on one of my columns? considering that is Populate it from database SqlDataSource
View 1 Replies
Apr 15, 2010
I want to write a LINQ to Entity query which does order by ascending or descending based on input parameter, Is there any way for that. Following is the my code.
public List<Hosters_HostingProviderDetail> GetPendingApproval(SortOrder sortOrder)
{
List<Hosters_HostingProviderDetail> returnList = new List<Hosters_HostingProviderDetail>();
int pendingStateId = Convert.ToInt32(State.Pending);
//If the sort order is ascending
if (sortOrder == SortOrder.ASC)
{
var hosters = from e in context.Hosters_HostingProviderDetail
where e.ActiveStatusID == pendingStateId
orderby e.HostingProviderName ascending
select e;
returnList = hosters.ToList<Hosters_HostingProviderDetail>();
return returnList;
}
else
{
var hosters = from e in context.Hosters_HostingProviderDetail
where e.StateID == pendingStateId
orderby e.HostingProviderName descending
select e;
returnList = hosters.ToList<Hosters_HostingProviderDetail>();
return returnList;
}
}
View 2 Replies
Sep 23, 2010
Just spent about 8 hours googling and looking through this forum for a solution on how to make sure that I can dynamically sort. Here is the situation.
I have 1 Gridview that displays 10 different scenarios based on what button is clicked.
I am also returning only top 10 records. I am doing all of the data binding pragmatically. So I have BoundFields, HyperLinkFields etc.
I also want to sort some records. When I change DataSource SQL statement the gridview somehow remembers what the last sort value was and it errors out saying that value "x" cannot be sorted because it does not exists.
I tried this:
Tried setting gridview1.sqldatasourceid = null; gridview1.allowsorting = false; gridview1.databind();
Here I get an error that says that the data source does not support sorting? Doesnt it say gridview1.allowsorting = false;
I also tried gridview1.sort("", SortDirection.Ascending); This does nothin... except query my database one more time because i have a onSorting event that looks like this:
[Code]....
Here is an example of just one of those SLQ statements inside GetSQLQuery:
[Code]....
View 1 Replies
Jan 12, 2010
I have a stored proc which returns months year in nice words, but having problem ordering them:
SELECT count(id) as counter, datename(MONTH, PublishDate) + ' ' + datename(YEAR, PublishDate) as date
from BLG_BlogPost where active=1 group by datename(MONTH, PublishDate) + ' ' + datename(YEAR, PublishDate)
And that returns:
April 2009 (8)
August 2009 (3)
February 2009 (2)
How can i order them?
View 3 Replies
Aug 14, 2010
i m using asp.net 2005 with access 2003. i need a code using vb.
how can i sort the record in descending order?
View 3 Replies
Apr 15, 2010
Order by descending is not working on LINQ to Entity In the following Query In place of ascending If I keep descending it is not working.
[code]....
View 1 Replies
Feb 27, 2011
Im doing something like this to get a list of all users that have been blocked:
public IQueryable<Aspnet_User> GetBannedUsers()
{
return db.Aspnet_Memberships.Where(x => x.IsApproved == false).Select(x => x.Aspnet_User);
}
Im doing this to block users:
MembershipUser user = Membership.GetUser(username);
if (user != null)
{
user.IsApproved = isApproved;
Membership.UpdateUser(user);
}
how can i get the list of banned users ordered by date they were banned.
View 2 Replies
Feb 28, 2010
i read Matt Berseth article also i downloaded this source. But i can not do sorting event. Everything is ok but sorting is not working.
[Code]....
View 3 Replies
Dec 13, 2010
I need to retrieve and display directory files in descending order. For example:
file-02_01_2010.txt should display before file-01_01_2010.
I am using DirectoryInfo.getfile(searchPattern) but that will return files in random order (or maybe ascending order, I am not sure). Is there a way to specify the order in which I need files to be returned? I know I can load them into an array, sort them, etc., etc., but is there any cleaner way?
View 7 Replies
Feb 8, 2011
I have a list of ids properly stored in a List<>. I now need to Group list and get a count of the number of occurrences sorted descending.
Example:
List<string> aryIDs = new List<string>;
aryIDs.Add("1234");
aryIDs.Add("4321");
aryIDs.Add("3214");
aryIDs.Add("1234");
aryIDs.Add("4321");
aryIDs.Add("1234");
Would Produce:
"1234", 3
"4321", 2
"3214", 1
This would be easy in TSQL, but I would like to avoid the server roundtrip, unnecessary tables, etc. if possible.
Update: The VB.NET conversion for Ralph Shillington's answer below:
[code]....
View 2 Replies
Jan 25, 2010
I have a column of type varchar that lists the values in this format:
SEP-09
SEP-08
OCT-09
OCT-08
NOV-09
NOV-08
MAY-09
MAR-09
JUN-09
JUL-09
JAN-10
JAN-09
I need to sort this list by descending order treated as actual date. I tried converting it to date and then tried to extract the year and month out but I keep receiving conversion errors. Does anyone know how to get this in the descending order to it shows up like this:
JAN-10
NOV-09
OCT-09
SEP-09
JUL-09
NOV-08
OCT-08
SEP-08
JUN-09
MAY-09
MAR-09
JAN-09
This is the closest I got but it keeps sorting the list alphabetically:
select distinct periodname, Convert(varchar,periodname,112) from periodtableorder by Convert(varchar,periodname,112) desc
View 2 Replies