Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 1st, 2004, 05:43 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default Sorting Is not working

HI All
sorting is working well with datagrid when its adjusted to autogenerate columns.

but when allowing sorting with bounded columns sorting headers are not activated.

the only solution for that is to create each column as a template and add a link to the header and activate sorting in itemcommand event.


how to fire sortcommand instead ??????



Ahmed Ali
Software Developer
__________________
Ahmed Ali
Senior Software Developer
 
Old March 2nd, 2004, 03:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Ahmed,

You can set the DataGrid's OnSortCommand to a method in your code, like this:

<asp:datagrid
 ID="myDataGrid"
 OnSortCommand="SortCommand"
/>

Then in your Code Behind, add a method with this signature:

public void SortCommand(Object sender, DataGridSortCommandEventArgs e)
{

}

Inside this method, retrieve SOrt information using e.SortExpression and rebind your data.

HtH,

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 2nd, 2004, 06:08 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

so i have to modify in html design,
can't do that visual or by code

Ahmed Ali
Software Developer
 
Old March 2nd, 2004, 06:22 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Sure you can.

Just, as with other EventHandlers, add some code like this to the InitializeComponent method:

myDataGrid.SortCommand += new DataGridSortCommandEventHandler(this.SortCommand);

Alternatively, you can switch to Design View, have VS.NET screw up all your HTML, then click your DataGrid once. On the Properties dialog, switch to the Events category, locate the SortCommand entry, type a new method name and hit Tab. VS.NET will add the Handler and the method for you in the Code Behind.


What's wrong with changing the HTML? I find this a useful and quick way to setup multiple handlers in Code View of the page.....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
window.opener working .... not working alyeng2000 Javascript How-To 5 January 5th, 2007 08:05 AM
Sorting not working correct Vishal_7 ASP.NET 1.0 and 1.1 Professional 0 February 21st, 2005 01:28 PM
Local COM working , but not working at Web Serv nagen111 .NET Web Services 3 February 19th, 2005 04:22 AM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.