473,473 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Datagrid Control Issue

The program was written by a different developer who never finished it.
Basically, it is a front-end to an Access database that probably should have
been done in Access itself. My question concerns the DataGrid control. This
control is used on about 30 different forms. The user wants to be able to
sort the data in a grid by clicking a column header. The AllowSorting
property is turned off on every grid in the project. I thought the fix would
be to set AllowSorting to true, but it is not that simple. If I set
AllowSorting to true, select a row, and click the Edit button, a form pops up
and displays the data that matched that row before the sort was performed.
For example, of the grid contains one column and three rows of data, B, C, A,
if I click the column header, the data is sorted as A, B, C. This appears
correct. However, if I select the second row, Instead of C, it displays B,
the data that was originally in that row.

Do you have any idea how to handle this? I have searched Google and Yahoo
for about 3 hours and I am getting some close, but no solid information. The
DataGrid is bound to a DataSet. I believe that sorting the grid does not
change the sort order of the underlying data. It just changes the way the
data is presented. This does make sense to me. If there was an event that
was fired when a sort is performed, maybe there is a way to resort that data
at that point. One other quirky thing that happens is every time I Edit
data, when I close the Edit form, the sort order reverts to what it
originally was. I don’t want that to happen.
Nov 21 '05 #1
2 993
John,

Unluckily is this not easy stuff.

Are you sure the datagrid is bounded directly to a dataset. Than you will
probably have a lot to rearange. Better is probably the
datatable.defaultview or dataview (which is the same however in another way
used).

This are links (beside MSDN.microsoft.com) with good datagrid information.

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp

http://www.microsoft.com/belux/nl/ms.../datagrid.mspx

I hope this helps?

Cor
"John R. Dougherty" <Jo************@discussions.microsoft.com>
...
The program was written by a different developer who never finished it.
Basically, it is a front-end to an Access database that probably should
have
been done in Access itself. My question concerns the DataGrid control.
This
control is used on about 30 different forms. The user wants to be able to
sort the data in a grid by clicking a column header. The AllowSorting
property is turned off on every grid in the project. I thought the fix
would
be to set AllowSorting to true, but it is not that simple. If I set
AllowSorting to true, select a row, and click the Edit button, a form pops
up
and displays the data that matched that row before the sort was performed.
For example, of the grid contains one column and three rows of data, B, C,
A,
if I click the column header, the data is sorted as A, B, C. This appears
correct. However, if I select the second row, Instead of C, it displays
B,
the data that was originally in that row.

Do you have any idea how to handle this? I have searched Google and Yahoo
for about 3 hours and I am getting some close, but no solid information.
The
DataGrid is bound to a DataSet. I believe that sorting the grid does not
change the sort order of the underlying data. It just changes the way the
data is presented. This does make sense to me. If there was an event
that
was fired when a sort is performed, maybe there is a way to resort that
data
at that point. One other quirky thing that happens is every time I Edit
data, when I close the Edit form, the sort order reverts to what it
originally was. I don't want that to happen.

Nov 21 '05 #2
Hi, John R. Dougherty
Solution:
Bind DataView to DataGrid.DataSource instead of binding DataTable to
DataGrid.DataSource.
The Data you use it for displaying should be from
DataView.item(datagrid.CurrentRowIndex).row, not from DataTable.row(
datagrid.CurrentRowIndex).
The issue is because datagrid is mapped to dataview, not mapped to DataTable.

Good luck
Nov 21 '05 #3

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

Similar topics

4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
1
by: Craig Banks | last post by:
If a row of data in a dataset has a lot of columns the row displaying the data in a datagrid will run way off the screen. What I'd like to do is display a row of data over several datagrid rows so...
2
by: Dimitris Pantazopoulos | last post by:
Hello. I am trying to do the simplest of things. These are exactly the steps I follow: 1. create an sqlConnection to an SQL Server database. 2. create a DataSource and produce a DataSet to a...
2
by: Joanne | last post by:
Hi, I have an "interesting" problem with UserControls in a datagrid and I'm desperate for your help as I work alone and have no-one else to ask. It is quite complicated but I'll try to keep it...
1
by: Sam Samnah | last post by:
Hi Everyone. It has been a long time since my last post. Nevertheless, I have built a custom server control that allows a user to edit text, bolding, italics strike though table insertion and...
7
by: Earl | last post by:
Any known fixes for the wacky right-alignment bug in the WinForms datagrid (VS2003)? I've tried Ken's workaround...
4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
6
by: Scott McDaniel | last post by:
I'm using Visual Studio 2005 with the .NET 2.0.50727 framework, and we're using the standard Datagrid control bound to a SQL Server. We have two groups of users - "full edit" users, and "view...
1
by: Rajesh Kumar Choudhary | last post by:
Hi, I want to use the system.windows.form.datagrid control present in .net 2005 or 2003. Is it possible to use this? Please let me know if it is not supported. I have seen and used the classes...
3
by: Brian Tkatch | last post by:
I have a form with two DataGrids, which are kept in sync manually via Stored PROCEDURE calls. That is, when a record is selected on the first grid, a stored PROCEDURE is CALLed to Fill() the next...
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,...
1
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...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.