After a user has clicked a column header to sort, how can I tell which
column header he clicked? In other words, how can I tell what order the
list is in after user changes it by clicking a column header?
Thanks,
-Carl 3 1467
Hey Carl,
the way this actually works is that when you bind to a datatable/dataset the
grid actually binds to the DefaultView property of the datasource. So, when
you click on the clolumnheaders, the sort property of this underlying
DefaultView is reset (based on which header you click).
that is the long of it just to give you an understanding of how the datagrid
works...
the short answer is to use the bindingcontext. something like...
ctype(me.myData Grid.BindingCon text(myGridsDat aSourceTable).C urrent,
DataRowView).Ro w
this line will get you the actual datarow that is currently selected in the
grid, regardless of the sort. (beware typos, it's late...)
hope this helps,
jim
"Carl Tribble" <ca*********@sb cglobal.net> wrote in message
news:eg******** *****@TK2MSFTNG P10.phx.gbl... After a user has clicked a column header to sort, how can I tell which column header he clicked? In other words, how can I tell what order the list is in after user changes it by clicking a column header?
Thanks, -Carl
If you want to know which column is sorted, I think you can retrieve the
dataView.Sort property for the DataView associated with your datagrid. You
can get this dataview through the CurrencyManager .
Dim cm as CurrencyManager =
CType(Me.DataGr id1.BindingCont ext(Me.DataGrid 1.DataSource,Me .DataGrid1.Data M
ember), CurrencyManager )
Dim dv as DataView = CType(cm.List, DataView)
' dv.Sort should hold the sorted column(s)
=============
Clay Burch, .NET MVP
Visit www.syncfusion.com for the coolest tools
"Carl Tribble" <ca*********@sb cglobal.net> wrote in message
news:eg******** *****@TK2MSFTNG P10.phx.gbl... After a user has clicked a column header to sort, how can I tell which column header he clicked? In other words, how can I tell what order the list is in after user changes it by clicking a column header?
Thanks, -Carl
Thanks Clay, that is exactly what I was looking for.
Thanks also to Jim, your input was useful too.
I have only been using this newsgroup a short time, but I love it!
-Carl
"ClayB [Syncfusion]" <cl***@syncfusi on.com> wrote in message
news:uo******** ******@TK2MSFTN GP12.phx.gbl... If you want to know which column is sorted, I think you can retrieve the dataView.Sort property for the DataView associated with your datagrid. You can get this dataview through the CurrencyManager .
Dim cm as CurrencyManager =
CType(Me.DataGr id1.BindingCont ext(Me.DataGrid 1.DataSource,Me .DataGrid1.Data M ember), CurrencyManager ) Dim dv as DataView = CType(cm.List, DataView) ' dv.Sort should hold the sorted column(s)
============= Clay Burch, .NET MVP
Visit www.syncfusion.com for the coolest tools
"Carl Tribble" <ca*********@sb cglobal.net> wrote in message news:eg******** *****@TK2MSFTNG P10.phx.gbl... After a user has clicked a column header to sort, how can I tell which column header he clicked? In other words, how can I tell what order the list is in after user changes it by clicking a column header?
Thanks, -Carl
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brett P. |
last post by:
Hello,
I am trying to have only one column sortable within a
data grid. I know you set the allow sorting property to
true on the style, but this enables sorting for all
columns. Is there a way to override this implementation
so that only a few or one of the columns may be sorted?
thanks,
-brett
|
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?
|
by: John Richardson |
last post by:
I've been bothered for some time about my DataGrid not populating my rows
very quickly. I have about 10K rows loading into the grid.
I create a datatable dt with 2 columns, an ID and a display. The ID is a
member of the keys array.
I then create a DataView dv over the table, and sort it by Display and ID
column (in case of duplicate Display).
I then set my DataGrid.DataSource = dv;
I then load the datatable with my rows, and this is...
|
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...
|
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.
| |
by: alan |
last post by:
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.Products.DefaultView
|
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.
|
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...
|
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
system.windows.forms.dll
I can't catch this Exception and it only occurs when I
|
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
|
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...
| |
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,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |