473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How can I sort datagrid?

Hi all
how can I make the interface for the user so he can sort datagrid?
thanks

Nov 16 '05 #1
3 7759
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

This site has everything you could want to know about the DataGrid

"taly" wrote:
Hi all
how can I make the interface for the user so he can sort datagrid?
thanks

Nov 16 '05 #2
Hi,

Usually what you do is sort the datagrid's datasource , if it's a
dataview/dataset you can use a Dataview for it.

I think I remember an article from Dino Esposito in MSDN magazine where he
sorted a HTML table ( which is the result of a datagrid in the client) try
searching in the MSDN archives.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"taly" <ta****@rad.co.il> wrote in message
news:cf**********@news2.netvision.net.il...
Hi all
how can I make the interface for the user so he can sort datagrid?
thanks

Nov 16 '05 #3
Please don't cross-post. Here is your answer:
Private Sub dg_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles
dg.PageIndexChanged
dg.CurrentPageIndex = e.NewPageIndex

'Sort the new page according to the last sort criteria
Dim dv As New DataView(dsCusts.Tables(0))
dv.Sort = ViewState.Item("lastSort")
dg.DataSource = dv

dg.DataBind()
End Sub

Private Sub dg_SortCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
dg.SortCommand
Dim dv As New DataView(dsCusts.Tables(0))
dv.Sort = e.SortExpression
dg.DataSource = dv
dg.DataBind()

'Store the desired sort criteria so that it can be applied when
paging occurs
ViewState.Add("lastSort", e.SortExpression)
End Sub
"taly" <ta****@rad.co.il> wrote in message
news:cf**********@news2.netvision.net.il...
Hi all
how can I make the interface for the user so he can sort datagrid?
thanks

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sandy | last post by:
Within my tag: <asp:DataGrid I'm using: AllowSorting="true" and OnSortCommand="Sort_Grid" which referrs to a method in my Codebehind file. (see Sort_Grid below) Since I have...
4
by: taly | last post by:
Hi all how can I make the interface for the user so he can sort datagrid? thanks
4
by: Joe | last post by:
Hello, I have a datagrid in an nested html table (one table inside of another table) and have set the allowsSorting property to true. I've created in the code-behind a method (Sub - I'm using...
3
by: mahtan | last post by:
Please help I have the problem that when I change the data in a Windows.Forms.DataGrid by a separate thread the following Exception is thrown: ThreadSystem.NullReferenceException in...
1
by: Tim | last post by:
In VB .NET I use datagrid to present information and when clicking on the column header, the entire datagrid is sorted. Besides CLICK, what're the other events associated with this type of action?...
3
by: Marco | last post by:
Hi, I'm new to datagrids and was hopping to get some help. I tried to bind an arraylist to a datagrid but the columns seem to be displayed in a random order for some reason. Is there someway that...
0
by: samir | last post by:
hi i have a datagrid where i display some columns. i want to have some columns from the db and 2 i calculate,i can display it but problem is how to sort the calculated columns. here is what i am...
0
by: KA NMC | last post by:
I have a dataGrid that is populated by SQL table. The Datagrid has two dynamic columns - that I created to for calculations. I want to sort the grid on frmload by one of the dynamic columns is that...
5
by: Ben | last post by:
Does anyone have any example code showing how to sort a datagrid that is bound to a custom class array? My code calls a web method that returns an array of type LeadListDS. LeadListDS consists of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.