473,326 Members | 2,104 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,326 software developers and data experts.

Sorting dynamically created columns in the datagird

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
Nov 18 '05 #1
2 1445
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.


Nov 18 '05 #2
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!
Nov 18 '05 #3

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

Similar topics

0
by: Karlo Swart via .NET 247 | last post by:
Hi. I am creating a dynamic datagrid. The columns are based on a request.querystring value. Eg: I will pass in a 'func=toys' parameter, which will cause the datagrid to load create columns...
12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
11
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...
2
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...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
1
by: tfsmag | last post by:
Hello, I have a function that returns a dynamically created gridview. This works fine, however it does not seem to be able to maintain state when adding sorting or paging to the gridview. Does...
0
by: ami | last post by:
Hi everyone, I have a question about dynamically adding columns to a gridview. Based on user input (after a button click), some columns are being added to my gridview. What I do: ...
4
by: Dan Grigore | last post by:
I am creating a table cell by cell (create the table, add columns, create row, add cells to the row) in which I want to add the capability for users to sort ASC and DESC by column header. Can...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.