Forms Data Controls :: Sorting Date Column In Gridview?
Mar 19, 2010
In gridview columns im displaying date and time, as below.
Im also doing sorting on these columns.
But the issue is during sorting its only sorting on "day (dd)"....
for example....these 3 values are from column, Date.
when I click for "Ascending" sort....it should get "17/03/2010 09:30:51" on the top (because of month 03) others have 02, but it doesnt, it gets in the above order, its just sort on day (dd).Below is my code for boundfield....
I have a datagrid with two columns ( File Name, and Date Created ). I want them to be sorted when clicked (ASC or DESC). I went into the design view and added the allow sorting feature and added the column names, so they are clickable in the header of the data grid. I also already added the onsortcommand as well.
My datagrid is named dgFileList and the onsortcommand method is named dgFileList_SortCommand.
The procedure that is already loading on page load is a DataSet. (where I think my problem is)I dont have anything in the back end beside the dgFileList_Sortcommand method. From what I have read, it seems like I can't use a DataSet to be sorted...I'm using visual studios 2005, C#, not VB.
I have a auto column generated GridView in a page, I have a dynamically binded column in that gridview, when page loads then sorting option is available on all other columns except that dynamically created column.
I have a gridview control bound to a sqldatasource in c#. In the rowdatabound event I look at a value in a cell and use a function to evaluate the value and depending on that value I populate an added unbound column in my bound datagrid to show an excalmation point. I now want to sort by the column with the excalmation point.
whn i click edit button on grid before sorting on any column it is working properly...but once i click on any column for sorting n thn click on edit then the rows get sorted again and edit is set on some other row... plz help me...herez my code..
Situation: SQL database, Linq to SQL class a ASP.NET page with a LinqDataSource and a gridview. The table has a ID field, a date field and a Serialnr field. In my Grid I like to Page on the datefield but to sort on the serialnr field ( or a selectable other field). Is that possible? Standard the paging is always done on the sort field and when you select a different sort field the page jumps back to the first page., and paging is then done over that sorted column.
I am looking to sort a column on my gridview by simply clicking on the column rather than clicking on the column header. In the design I have been given, the column header will not be shown, and I need to be able to give the user to sort this column, by simply just clicking any where on the column.
I m working with VS-2005 without ajax functionality(With out Update Panel). I have a gridview which has a two colmn inside first column there is image. When user clicks on the image a pop up form with calender control should open when user selects the date from calender that date should get sets up in second column
Moderators Note: THIS ISSUE IS BIG FOR ME AND EVEN IF POSSIBLE, GET THE REPLY FROM THE DESIGNER OF GRIDVIEW. I have been looking for him for long. I am really fed up with reviewing a good lot of web pages on how we can possibly customize the gridview to enable sorting and paging. So many sites have listed out a lot of information and so many guidances. But the problem is that one works out fine and the other is a burden. I really feel bad about being given the job of customizing this kind of a gridview which has no user friendly approach to it. Also, this control is rendered without the pager links inside the <tfoot> tag. I have tried the Pear Pager in php. It is that good and easy to use and compared to that, the gridview in asp.net is the worst ever control i have ever tried so far.
1. i can use the images to indicate the sorting direction 2. I can have the custom pager like
<<Previous 1 2 3 .. 7 Next >>.
When i click the next when i am viewing the page at 3 , the pager links should change as
<<Previous 2 3 4 .. 7 Next >>
Kindly look into this type of requirement and firstly tell me whether this is possible with the gridview control. I would like this request even to be escalated to the designers of the gridview control also, so that Microsoft comes out with a reply THAT WORKS and not the kind of stuff like surfing through a lot of links and pages and finally wasting a lot of days precious time and still breaking the head with this useless control. I have spent a lot of time in searching for a perfect way. Not writing a code that is non-standard. I am really serious b'cos I have spent weeks in customizing this control. If I dont get a solid reply atleast now, I am going to generate all the output by HTML content by custom coding.
I've got a datagrid which i wanted to sort, since i dnt have much knowledge of .Net, so what i did was to save that datagrid in a DataTable, then again save the same DataTable in a DataView, then apply sorting on that DataView. this is the code, and its working fine.
but the issue comes when the i try to sort the Date Column, the dates are in MM/DD/YYYY format, so if i try to sort the date column, the dates are sorted on month basis, rather than year basis. now i cant change the date format, is there any way to sort dates in DataView?
I have a Gridview, which I bind to a Dataview programtically. My Gridview has 11 columns. Sorting works fine as long as I do not remove any columns programtically.
In certain cases I remove 2 of the columns from the Gridview. Still not a problem. All the data is properly displayed however the problem occurs when I sort one of the columns. I sort the Dataview and bind to the Gridview again. Data from two of my columns just vanishes. Both of these columns are based on ItemTemplates. The columns are still displayed but just empty cells.
I need to check for two differect text to make the Edit button inactive. For example, I need to make the button inactive when the ActionTypeName field has value either Accepted date or Received date. I can do one check with Accepted date but not both.
Split off from http://forums.asp.net/t/1595139.aspx:
I have an additional column called 'KPI %' in my gridview that calculates the percentage of two template fields and thus I cannot use the sortexpression on it. How can I sort the contents of the 'KPI %' column in ASC or DESC format?
I have an item template field retrieving a date field from an Oracle 11g database that can be null. The date is converted to a string before binding to the gridview. When the column is sorted is is being sorted as a string. I have read in several places if you add a formatting string to the eval statement in the item template that the sort operation will then sort the string as a date. However, I cannot get it to work. I also tried a bound column, but the column is still being sorted as a string.Code from the aspx page:
I have a Gridview with a templated column which contains just a label.
I set the Label1.text during GridView1.RowDataBound based on doing a DataBinder.Eval(e.Row.DataItem,"myColumn") and a calculation off that.
When the user clicks the header I want it to sort based on what's in the Label but instead if seems to be sorting on the contents it was bound to, "myColumn", even though that's not what appears in the grid.
I have autogenerated columns some columns come from db and some are virtual columns what i am adding to a dataset that consist of columns from db.i want to disable sorting for the virtual columns which i add to dataset
I have SQL2012 database, which has a Table with many columns in it . One of the columns is "Start Date" and i set the dataType to "Date". Now I am putting the data into a gridview but the data is different to the database, the "Start Date" column has time as well. why this is happening ( the Start Date column is the gridview is a BoundField).