473,654 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting of datagrid column

I set the datagrid to be sortable,
sort expression = "Column1 asc"

but when i click the column name
the datagrid doesn't load anything, did i miss sth. on the sorting? thanks a
lot!!

in Sort_Command event handler

Dim SortView As DataView = DataSet11.Produ cts.DefaultView
SortView.Sort = e.SortExpressio n
DataGrid1.DataS ource = SortView
DataGrid1.DataB ind()

Nov 19 '05 #1
2 1292
I am not sure how your entire code look like.
I suggest you to take a look at this small example in below article.
http://www.dotnetjunkies.com/Article...0D57699C3.dcik

Sachi

"alan" wrote:
I set the datagrid to be sortable,
sort expression = "Column1 asc"

but when i click the column name
the datagrid doesn't load anything, did i miss sth. on the sorting? thanks a
lot!!

in Sort_Command event handler

Dim SortView As DataView = DataSet11.Produ cts.DefaultView
SortView.Sort = e.SortExpressio n
DataGrid1.DataS ource = SortView
DataGrid1.DataB ind()

Nov 19 '05 #2
i am using asp.net (VB), and Access Database
i make the connection and make a datagrid from the OleDbAdaptor

I tick "allow sorting" and enter "colName asc" as sort expression the
property builder of the datagrid

i want to use the "dataview" approach to sort the columns
if i add "if not me.ispostback", nothing will be loaded after click the
column head
if not add, the column will give no response even i click the column head

thanks a lot!

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
OleDbDataAdapte r1.Fill(DataSet 11)
datgrid1.DataBi nd()
End Sub

in Sort_Command event handler

Dim SortView As DataView = DataSet11.Produ cts.DefaultView
SortView.Sort = e.SortExpressio n
DataGrid1.DataS ource = SortView
DataGrid1.DataB ind()
"Sachi" wrote:
I am not sure how your entire code look like.
I suggest you to take a look at this small example in below article.
http://www.dotnetjunkies.com/Article...0D57699C3.dcik

Sachi

"alan" wrote:
I set the datagrid to be sortable,
sort expression = "Column1 asc"

but when i click the column name
the datagrid doesn't load anything, did i miss sth. on the sorting? thanks a
lot!!

in Sort_Command event handler

Dim SortView As DataView = DataSet11.Produ cts.DefaultView
SortView.Sort = e.SortExpressio n
DataGrid1.DataS ource = SortView
DataGrid1.DataB ind()

Nov 19 '05 #3

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

Similar topics

1
2057
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going to scroll the table up and down or from right to the left the content of the active cell will be selected as if for copy/paste. How can I deactivate such a behaviour?
3
3122
by: melanieab | last post by:
Hi, I'm programatically sorting in a datagrid. When a column header is clicked, the sort happens twice for some reason, making it looks like it only sorts in descending order. I can tell it sorts twice because I inserted a messagebox in the dgMouse (MouseUp) event. Before ok is pressed, the table changes from the order it was loaded to ascending order. After ok is pressed, it goes to descending. The code is below. Any idea why...
0
1378
by: Robert Brinson | last post by:
Hello all! I'm running .NET Framework 1.1 using VS.NET 2003. I've got a mystery with a DataGrid. Below is the definition of the DataGrid from my aspx page: </asp:datagrid><asp:datagrid id="dgDetails" Runat="server" Width="100%" Visible="False" AllowSorting="True" CellPadding="1" CellSpacing="0" AutoGenerateColumns="False" OnSortCommand="SortDetails"> <ItemStyle Font-Size="XX-Small" Font-Names="Tahoma"></ItemStyle> <HeaderStyle...
4
1700
by: Richard | last post by:
When i try sorting in the database, it sorts the numbers: 0 1 102 2 304 305 4 etc....
11
2138
by: rkbnair | last post by:
I have created a datagrid in my aspx with the 'AllowSorting' property to true. When clicking on the column header, the page refreshes. However the sorting is not done. Am I missing anything? I populate the data if !postback.
2
3145
by: saleek | last post by:
Hi, I am trying to figure out why my datagrid has stopped firing the page and sort commands. Scenario: I originally had template columns in my datagrid and had set up custom bi-directional sorting as well as paging of the datagrid records.
2
1309
by: Lars Netzel | last post by:
I have a Datagrid using the Edit/Update mode to alter data in the datasource. I needed to have a bit more flexible interface in the editmode with a design that couldn't work in the columns. So I fixed this by only having ONE template column (plus the edit button column) and then have html tables in both the header and the edit items to have complete control over the design. This works fine. Now my boss wants Sorting in the column...
8
15161
by: simchajoy2000 | last post by:
I thought the only thing I had to do to disable column sorting in VB.NET was to set datagrid.AllowSorting = False. Unfortunately this has never worked for me. I discovered another set of code that seems to work for 99% of the cases where I need to disable datagrid column sorting: Private Sub datagrid_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles datagrid.MouseDown Dim pt As New Point(e.X,...
4
3094
by: Ambica Jain | last post by:
Hi, I want custom sorting on some of the columns in the datagrid. And i am able to do the same by overriding MouseDown event. However, i need to rebind my datatable to reflect the changes in grid. And with rebinding, sorting image (little triangle on the column header) goes away. I need to show sorting image as well custom sorting. Please help. Thanks
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.