473,396 Members | 1,998 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,396 software developers and data experts.

DataGrid Sorting - bidirectional

Hi,

I want to sort the DataGrid according to the number of clicks of mouse on
the column-header link.
e.g.
if user clicks on the header once - it will be sorted ASC
if the header is double-clicked - it will be sorted DESC

It is not exactly toggling the sorting-order. I have seen a lot of messages
and articles in the web about toggling the sort order (like first time click
will generate ASC sort, next time click will generate DESC sort and so on).

But my requirement is how to catch single/double-click of the mouse on the
column header and fixing the sort order accordingly.

Any ideas ?

Thanx
Snig.

Nov 18 '05 #1
2 1840
I'd say it is not a normal requirement. You have some work to do here. First
of all, you can catch the double click and differentiate it from the single
click using javascript client side. It would be a little messy to move that
double click to the server side just like the single click which is mapped
by default. I suggest you convert your code to sort the datagrid client
side. You can then customize the grid to sort based on the either the single
click or the double click. Here is a link to sorting a datagrid client side.
Hopefully, you can put the two together. Before you go converting code,
research to see whether or not you can map a double click to a code behind.
I don't know if it can be done and frankly, I haven't seen it either, but
it's worth a shot.
http://v4cnet.europe.webmatrixhostin..._repeater.aspx

--
Regards,
Alvin Bruney
Got Tidbits? Get it here
www.networkip.net/tidbits
"Snig" <sn****@yahoo.co.in> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
Hi,

I want to sort the DataGrid according to the number of clicks of mouse on
the column-header link.
e.g.
if user clicks on the header once - it will be sorted ASC
if the header is double-clicked - it will be sorted DESC

It is not exactly toggling the sorting-order. I have seen a lot of messages and articles in the web about toggling the sort order (like first time click will generate ASC sort, next time click will generate DESC sort and so on).
But my requirement is how to catch single/double-click of the mouse on the
column header and fixing the sort order accordingly.

Any ideas ?

Thanx
Snig.

Nov 18 '05 #2
try this

protected string SortField

{

get

{

object o = ViewState["SortField"];

return (o == null) ? "": (String)o;

}

set

{

ViewState["SortField"] = value;

}

}

private void dg1_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)

{

dg1.CurrentPageIndex = 0;

if(SortField.EndsWith(" DESC"))

{

SortField = e.SortExpression;;

}

else

{

if(SortField == e.SortExpression)

SortField = e.SortExpression + " DESC";

else

SortField = e.SortExpression;

}

BindGrid();

}
Nov 18 '05 #3

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

Similar topics

11
by: velthuijsen | last post by:
I tried taking a list and pass it through std::sort like the following: sort(Unsorted.begin(), Unsorted.end()); I got an error back stating that the list iterator doesn't have a binary...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
3
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...
4
by: mark | last post by:
i have populated a datagrid succesfully and enabled sort successfully except its not bidirectional - how do i do this ? this is my code for sorting Private Sub DataGrid1_SortCommand(ByVal...
4
by: Manny Chohan | last post by:
hi guys, my code is returning an array and i need to create datagrid so that i can have sorting and implement prev....next function on it to navigate. is there any way this can be done in...
0
by: Roy | last post by:
Hey all, I must be losing my touch. I have made many pages in the 1.1 framework that utilize custom bidirectional paging in datagrids. We've converted over to 2.0 and I've been trying to use the...
3
by: Mark Gilkes | last post by:
Hi, I have an aspx page in which I am building a DataGrid control in the code-behind dynamically. The DataGrid is declared along with BoundColumns and bound to the datasource, then added to a...
1
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

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.