473,394 Members | 1,750 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,394 software developers and data experts.

c#.net datagrid sorting

Hi,
I am new to C#.net and am in the learning curve.
I designed a c#.net data grid that connects to my local DB server to display the table data.

I want to enable sorting to this data grid by one particular column name, could anyone help me in this regard please. Let em know if there are any questions that I can provide answers to.

Thanks,
Tanya
May 20 '08 #1
6 5223
Plater
7,872 Expert 4TB
Do you want it allowed on ONLY one column, or on all of them?
What version of .NET are you using? (Determines if you can use DataGridView or not)
May 20 '08 #2
Do you want it allowed on ONLY one column, or on all of them?
What version of .NET are you using? (Determines if you can use DataGridView or not)

----------------

Thanks for the prompt reply.

Answer is Yes, I just want to sort the data grid with just one column in the grid.
Dotnet version: 2.0.

Sorting the grid insense, say for ex: the column names are status,severity,name.
I want to sort the data grid by the status. If I select the status as open /close the grid should display values accordingly.

Does this answer your question?
May 20 '08 #3
Plater
7,872 Expert 4TB
Maybe, be default (I think) when using the DataGridView object (which you should be using) all the columns can be sorted ascending/descending just by clicking on their name.
I think you can over-ride this ability and cancel any clicks on the columns you don't want.

Check the SortMode property on Columns (and ColumnSortModeChanged event on the DataGridView) to get you started.
May 20 '08 #4
Maybe, be default (I think) when using the DataGridView object (which you should be using) all the columns can be sorted ascending/descending just by clicking on their name.
I think you can over-ride this ability and cancel any clicks on the columns you don't want.
=====

I am sorry, I think I didnt follow what you said completely. Is there any property I can set to enable this sorting ascending/descending order? I actually set the
enable pagesorting/paging callbacks to true in the grid view properties. But unable to see the changes on the browser. Do I have to do something on the code behind as well?

Thanks,
Tanya
May 20 '08 #5
=====

I am sorry, I think I didnt follow what you said completely. Is there any property I can set to enable this sorting ascending/descending order? I actually set the
enable pagesorting/paging callbacks to true in the grid view properties. But unable to see the changes on the browser. Do I have to do something on the code behind as well?

Thanks,
Tanya
===========================

can someone help me in this, please!
May 21 '08 #6
Plater
7,872 Expert 4TB
Ah ha!
You're doing a web application, so the object is GridView, I think that actually makes it easier.
Turn on the column sorting, then attach a handler to the sort event. Then if the column is not the one you want to be allowed to sort on, descard the event and don't perform the sort.
There is probably something you could do in the rowdatabound event that will keep all the columns in the header row from showing clickable links too.
May 22 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Chris Mayers | last post by:
I have a Windows Forms DataGrid that has a DataView as a datasource. My problem is that I want the datagrid to exhibit some special sorting properties when the header rows are clicked on. From...
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...
1
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going...
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...
7
by: DC Gringo | last post by:
I have a datagrid that won't sort. The event handler is firing and return label text, just not the sort. Here's my Sub Page_Load and Sub DataGrid1_SortCommand: -------------------- Private...
1
by: Jeremy | last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current...
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...
5
by: DKC | last post by:
Hi, Using VB.NET. I have a datagrid having a strongly typed array of objects as its data source. The data from the array of objects is displayed by means of a table style, which is fine, but...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.