Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Sorting dynamically created columns in the datagird

Reply
Thread Tools

Sorting dynamically created columns in the datagird

 
 
Gaurav Gargate
Guest
Posts: n/a
 
      10-05-2004
To Group,

I am creating a datagrid in an ASP.NET project (C#) at the design time.
I will be adding the columns to the datagird at run time.
The number of columns, name of the columns, data in the rows etc. will all
be decided on the run time.
I am using the simple grid.Columns.Add(BoundColumn).... method.

BUT I am not able to sort these columns even if the AllowSorting property
has been set to true.
I cannot capture any event when I click the header of the data grid.
The page is posted back on clicking the header but no event is fired.

How can I sort the columns created on the run time.

Thanks in Advance,
Gaurav


 
Reply With Quote
 
 
 
 
=?Utf-8?B?c3Jpbmk=?=
Guest
Posts: n/a
 
      10-05-2004
hi Gaurav,
You need to give the sort expression for each column that you are adding.
In the datagrid_sortcommand event you have to get the sortexpression of the
datagrid and sort the datasource on that column and rebind the datasource to
the datagrid.
Check out this link for an exampl
http://samples.gotdotnet.com/quickst...d.aspx#sorting
HTH
srini

"Gaurav Gargate" wrote:

> To Group,
>
> I am creating a datagrid in an ASP.NET project (C#) at the design time.


 
Reply With Quote
 
 
 
 
Gaurav Gargate
Guest
Posts: n/a
 
      10-06-2004
Hi Srini...

Thanks for the urgent reply.
Infact I had tried out everything that is displayed on the link you
sent. Just forgot to mention that in my post..

The problem was that the dynamically generated columns on the datagrid
did not generate/evoke any event. So was not able to catch any of them.

I have however found a way round. I have allowed the auto creation of
columns on the datagrid and bound the data grid to the dataset I get.
This has resulted in dynamic columns, as well as all the events are been
captured.

Regards,
Gaurav





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
database columns vs. gui columns and sorting ittay.dror@gmail.com Java 5 03-04-2006 10:48 AM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
sorting dynamically created columns in a datagrid Korneel Vandamme ASP .Net Datagrid Control 0 09-30-2004 10:48 AM
eventhandler of a programmatically created datagird Anna Schmidt ASP .Net Datagrid Control 1 03-02-2004 07:13 PM



Advertisments