473,804 Members | 3,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1864
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.c o.in> wrote in message
news:O9******** ******@TK2MSFTN GP10.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.W ebControls.Data GridSortCommand EventArgs e)

{

dg1.CurrentPage Index = 0;

if(SortField.En dsWith(" DESC"))

{

SortField = e.SortExpressio n;;

}

else

{

if(SortField == e.SortExpressio n)

SortField = e.SortExpressio n + " DESC";

else

SortField = e.SortExpressio n;

}

BindGrid();

}
Nov 18 '05 #3

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

Similar topics

11
5797
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 substraction operator. Peeking in the algoritm header file it's clear why seeing that sort there calls _sort(_First, _Last, _Last-_First) which might be a tad challenging seeing that the different values stored in a list do not need to be stored...
2
945
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 datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
3
3128
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...
4
1381
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 source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid1.SortCommand Dim strConn As String = connectionstring Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
4
2117
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 codebehind file. I am using c#. Thanks Manny
0
1564
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 built-in functionality of gridviews and objectdatasource's to accomplish the same thing (w/o resorting to the 1.1 methodology). I discovered two very nice and comprehensive articles concerning this: Custom Paging in ASP.NET 2.0 with SQL Server...
3
3772
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 panel control in the OnInit method of the aspx Page. I am trying to implement a bidirectional sorting. I have a SortCommand method which fires OK. I have followed the code example given on the 4GuysFromRolla site, which reads the value from...
1
7147
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 the first column in the grid only. I havent found a way to reliably do this yet. I tried putting the following code in the datagrid's mouse down event Dim hti As DataGrid.HitTestInfo
0
2093
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 help........pls urgent ========================================================= <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
0
9705
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
9576
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
10567
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
10323
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
6847
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();...
0
5515
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2983
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.