Web Forms :: DataView.Sort Vs List.sort?
Mar 7, 2010Actually 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 RepliesActually 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 RepliesI have a datatable which contains the summery row as well. I just assign the datasource property of a gridview and call databind method to fill and display the records.
Now, when I applied sorting through dataview to the gridview, the sorting happens along with the summery row, which is a normal behavior. As a result the "Total" - column took place inside the data some times. I want to prevent this.
The best way out for that can be done by creating the summery row at grid view row databound. But unfortunately I could not change the datatable as per this requirement.
Can the dataview sorting exclude the last row of the datatable through any process?..
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.
I have a gridview with some columns and I need to sort the gridview by a date-column. But it doesn't sort it correctly. This is the code I use:
dt.DefaultView.Sort = "Meldingsdatum asc";
gvOutlookMeldingen.DataSource = dt;
gvOutlookMeldingen.DataBind();
I have a simple dynamic gridview with following code -
GV = new GridView();
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 RepliesI have a page which lists all the files in a particular folder (all PDFs), using a data-table and gridview.
I'm currently sorting this table by the filename (by using a dataview), which isn't that helpful, and I want the gridview of files sorted by the file created or file modified date (as recorded in Windows).
If that's not possible, a second option would be to extract the date from the file name string (no problem doing that), and sort the dataview/datatable or gridview based on that. Example Filename: DailySalesReport-1-15-2010. My only hangup with this is how do I sort on date, when it's a string value? Convert to date? How would I sort the whole dataset based on this converted value?
[Code]....
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]....
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]....
I retrieved values from database to drop down ,how can i make them as sortable.
View 5 Repliessort List-generic object by two parameters
View 1 RepliesAs I am new to listview i had a problem with it, I hav to sort the values in the list view, when we click on the header links, so i hav done it by
commandname="sort" and commandargument="My_table_column", and i hav suceeded doin it.
Now my problem is i hav to do some search by 6 conditons like
CustomerId,CustomerName,OrderNumber,OrderDate,OrderType
For this i am using row filter and filtering the values in the Dt and then i am binding the dt back to the ListView here i am getting the problem as "The data source does not support sorting". I am aware that i am changing the data source, but before binding the datasource manually to
dt,
i hav tried doing this to make the datasourceid null which i hav attached previously
lvSalesLayOut.DataSourceID = "";
But i am getting the error post me how to get this done programatically.
If I have a specific order that I want to sort my List by, how do I do that? For instance, I have a list of items (coming from a database), with ID's ... and they come in order, i.e 1, 2, 3, 4. After receiving this list, I'd like to reorder the list above based on a specific order, e.g. 2, 4, 1, 3. How do I do this without complicate it too much?
View 11 RepliesI have class like
public class ProgressBars
{
public ProgressBars()
{ }
private Int32 _ID;
private string _Name;
public virtual Int32 ID {get { return _ID; } set { _ID = value; } }
public virtual string Name { get { return _Name; } set { _Name = value; }}
}
here is List collection
List<ProgressBars> progress;
progress.Sort //I need to get sort here by Name
how can I sort this collection by Name?
I have a class called Questions. This Questions has properties QuestionID and QuestionAnswer. My list of Questions has QuestionID like 2,3,4,15,12,24,22,,,, etc I need to sort this List of Questions Object based on QuestionID and store in another Questions object.
View 2 Repliesthe specific example i am referring to is this site [URL] notice the sort by drop down list. basically i want to sort products according to price,name,popularity? do i have to requery the database and retreive the sorted data in gridview again, or should i already sort the items in the gridview that are already there? I tried to this but its the wrong approach, basically i was trying to repopulate data in the page load event, which was giving error.
View 2 RepliesI am trying to correct the sort order of my ASP.NET drop down list.
The problem I have is that I need to select a distinct Serial number and have these numbers organised by DateTime Desc.
However I cannot ORDER BY DateTime if using DISTINCT without selecting the DateTime field in my query.
However if I select DateTime this selects every data value associated with a single Serial number and results in duplications.
The purpose of my page is to display data for ALL Serials, or data associated to one serial. When a new cycle begins (because it is a new production run) the Serial reverts to 1. So I cannot simply organise by serial number either.
When I use the following SQL statement the list box is in the order I require but after a period of time (usually a few hours) the order changes and appears to have no organised structure.
I have a check-box-List which I bind to a master dataTable(DTA)... I have another dataTable (DTB) which has the values that needs to checked in the check-box-List... So I loop through all items in the check-box-list to see if it exists in the DTB and set checked = true for those items that exists. Now I want to show the checked items first in the Check-box-list box and the unchecked items below that. Is there any way I can do it... A similar solution for List-Box could also be helpful. A Javascript hint is welcome too.
View 1 RepliesI am using jQuery for custom sorting my <ul><li> list.But I have a problem. I can sort and move those <li>-s but problem is I don't know how to update database with new order integers.Example of html ul li:
[Code]....
This is an example of my li element.. I have id=43, thats Id of picture in database.I use this javascript for trying to somehow make array and read that id into array:
[Code]....
Problem is I don't know exactly what am I doing wrong, because my event doesn't fire, when I press "update button.. Update button fires "update" function on click:
[Code]....
I hope someone will try to explain.Do codebehind and html needs to be in the same document? Can I use ascx and use "update" button there, to fire aspx methode?
I am using Visual Studio 2008 and SQL Server 2008, I have a drop down list on my page that gets its data from SQL. My SQL tabel only has 2 columns, "HeaderId" and "Header". So on my drow down list I have the value field set as the "HeaderId" and the text field set as the "Header". What I need now is that when it is bound to the list to be in order of the "HeaderId". I tried doing and ORDER BY but it did not work. What can I do, is there a better way of doing this? Here is my code to populate the list:
[Code]....
I am dynamically binding the treeview using DOM.
I m populating the tree by sayin treeview1.nodes.add(Treenode)
After this, i need to sort them alphabetically. I have followed this ref:[URL] but I was not able to understand how to do it only for parent nodes, since I don't have child nodes.
Moreover I m not able to get property sort().
How do I achieve this?
I have the following array list:
1. AlbumName
2. AlbumName
3. AlbumName
4. AlbumName
5. AlbumName
I would like this sort as follows(Csharp.net):
5. AlbumName
4. AlbumName
3. AlbumName
2. AlbumName
1. AlbumName
This is my House_info and House_product table
House_info
Id
Behcode
Name
Description
address
H_name
[code]....
And this is my SP that fill my datalist with this SP from House_info
ALTER procedure [dbo].[test1]
as
begin
select substring([Description],0,45)+'...' As Description , substring([address],0,26)+'...' As address, Name
from House_Info
end
COlumn Behcode is same in 2 table
I want SORT column in House_info table by DATE COLUMN in House_product.
<asp:GridViewid="gridview"
runat="server" DataSourceID = "SqlDataSource1"
PageSize="30" EmptyDataText = "No Records Found" EmptyDataRowStyle-HorizontalAlign ="Center"
AllowPaging="true"
HorizontalAlign="Center" BorderColor ="Black" Width = "762" Font-Names="Calibri"
[Code] ....
First time on page load
Sorting works fine
But if I done sorting on gridview column then its always the same , How to assign result of SQL query to my result
so that my sort will show result from sql query order not the order of grisview sort ...
now i use the dataview to sort the seq of datatable and bind to repeater, it can only display the seq correctly.but i found that it is not the actual database seq, when i remove the row from the datatable, it is not remove the record that i see from the UI.do i need to sort the seq to the actual datatable not the dataview.now i use the seq (int) in datatable to sort the datatable as belows:
DataView view = dt.DefaultView;
view.Sort = "SEQ";
repeater.datasource=view;
repeater.databind();