473,396 Members | 1,702 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 programatically - How?


Hi all,

I need some advice on how to sort the contents of a datagrid from code. The
issue I have is a client that wants the datagrid to show its rows in "entry"
order (i.e. the order in which rows appear in the database) after performing a
new search to find some rows. This is actually how a datagrid will initially
show its rows, but after the user clicks a column header, the datagrid will
forever after show rows sorted according to that column.

There seems to be no way to get back to the "entry" order after that. I need a
way to reset the default ordering from the code, so that each search the user
does will revert to the unsorted display. Looking in the datagrid
documentation provides no help at all. In my particular usage, I have the
datagrid tied to a dataset.

Thanks to any who can help.

--
Junkguy
Nov 15 '05 #1
1 2104
In article <ju***************************@news-server-fe-01.columbus.rr.com>,
Junkguy <ju*****@columbus.rr.com> wrote:
I need some advice on how to sort the contents of a datagrid from code.


Ok, nevermind I got it:

Datagrid dg;
...
DataTable dt = (DataTable) dg.DataSource;
dt.DefaultView.Sort = "";
At least it seems to work. Somebody let me know if this is a bad idea.

Thanks.

--
Junkguy
Nov 15 '05 #2

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

Similar topics

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...
1
by: mg | last post by:
I have created a databound datagrid programatically (that is, without wizards) in my C# codebehind How can I programatically add sorting and paging to this datagrid?
0
by: Eric | last post by:
Hello, I have a datagrid with sorting enabled. When clickong on the colum names in the header the datagrid is sorted no problem. Unfortunatly, I have a graph that needs to be generated for each...
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: Chris | last post by:
Ok, I think this is an easy one - I've just been staring at it too long. I'm creating a datagrid in asp.net/c# from scratch, i.e. nothing at all in the aspx page. I'm also creating all the...
3
by: DBC User | last post by:
When you sort a column in a datagrid, it sorts the rows based on the column and display it properly, but it looses the orignal row which it was focused before sorting? How can you make it to keep...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.