473,324 Members | 2,166 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,324 software developers and data experts.

GridView Sorting

Hai to all

I have a grid view controll, In that controll throgh the datatable am loding the data to the grid view, Now the question, is it possible to sort the gridview when clicking on the coloum header based on that coloumn header,

If it so any body can help me to do so, (Am not using the sql datasource controll to load the data to the gridview)

By Ashraf
Nov 21 '07 #1
5 1302
mzmishra
390 Expert 256MB
sorting is possible in grid view.
in the SortOrderChanged event handler keep a dataview and sort that.
Nov 21 '07 #2
Could u make little bit brief, Am new to the gridview, So I cant follow what u told
Nov 21 '07 #3
Anybody help me to solve the problem
Nov 21 '07 #4
Frinavale
9,735 Expert Mod 8TB
Could u make little bit brief, Am new to the gridview, So I cant follow what u told
GridViews have 2 events for sorting:
The Sorting Event and the Sorted Event.

What you need to do is is set the GridView's AllowSorting property to True, make sure that the columns that you want to sort are BoundFields and then properly implement the method that handles the Sorting Event.

Eg
Expand|Select|Wrap|Line Numbers
  1. Protected Sub GV_MyGridView_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GV_MyGridView.Sorting
  2.       Dim se as String = e.SortExpression 'this stores the sort expression for the column that the event was fired for
  3.       'It is here that you will write the code to sort the GridView column according to the business logic that your program requires.  Once you are done sorting the data source be sure to rebind the gridview or your changes will not take effect
  4.  
  5. End Sub
For more information on GridViews please see the article provided by MSDN on the GridView Class
Cheers

-Frinny
Nov 21 '07 #5
Thanks for ur valuable comment Frinny...
Nov 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
2
by: Arjen | last post by:
Hi, I get this error message when sorting a gridview: The GridView 'GridView1' fired event Sorting which wasn't handled What do I need to do? Thanks!
4
by: samb | last post by:
When I use manual databinding to a GridView control, as bellow. 'Retrive a DataSet from database Dim ds As DataSet = uda.GetUsers(conectionString) 'gvUsers - The GridView gvUsers.DataSource...
4
by: kurt sune | last post by:
I have a an aspx page with a gridview. The gridview is data bound to a generic list of custom classes. The gridview's DataSource is thus not set. Now I want to add sorting to it. So I create...
0
by: jobo | last post by:
Hey there, I'm having a problem getting sorting to work. Here's what the GridView looks like: "server" ID="updt1" Mode="Conditional">
2
by: sivagururaja | last post by:
Hi All, How can i sorting the Gridview Columns via the code behind. When i tried to sorting the column it doesn't work. SqlConnection con = new SqlConnection("Connection string");...
4
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have a vb.net 2.0 app that is loading a GridView with a DataSource that is returned from a function. The definitions in the function are: Dim ReportDS As DataSet = New DataSet Dim...
3
by: =?Utf-8?B?YmJkb2J1ZGR5?= | last post by:
I have a question that maybe somebody can help me out. I have a gridview that is bound to a sqltable, and I have created two template columns. I am having problems getting the sorting to work....
3
by: Nathan Sokalski | last post by:
I have a GridView control with three columns, all BoundField columns. They all have a HeaderText and DataField property set, and the third one has a DataFormatString property as well. When I run my...
0
by: Sobin Thomas | last post by:
Hi All, How can I bind the Gridview control to Sql Datasource control on a button click(I see majority of the articles binding datasource at page load) I need to enable the paging and sorting of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: 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: 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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.