473,729 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: DataGrid Sort

Hi

I have a question which I hope you can help with.

I am setting the DataSource of a DataGrid to be a DataView. I am sorting the
DataView by various fields which include a Date.

When I create a new row in the DataGrid and set the date to me within the
current sort range, the newly created row "jumps" to its correct position in
the grid. This obviously makes sense because it is following the sort rule.

However, I would like to be able to achive the following:

(1) Display the DataView in the DataGrid initially sorted using the rules
specified.
(2) New rows can be added to the DataGrid BUT no sorting will occur.
(3) If a button is pressed, then the grid will re-sort using the sort rule
specified initially.

I don't know if it makes any difference but the DataView I am using is
global to the form.

I hope somebody can help.

Many thanks in advance

G
Apr 2 '06 #1
4 1541
Hi,

Be aware that this acts probably different in versions 2002/2003 and 2005

The dataview should be dynamic but is that not always in 2002/2003

As well is there a bug that put a newly added datarow at the end in some
situations of the datagrid. Exactly in fact as you want.

But making use of that bug is not the best thing to do.

I hope that you understand because of this that your question is difficult
answer

Cor

"G .Net" <no********@ema il.com> schreef in bericht
news:ue******** ************@pi pex.net...
Hi

I have a question which I hope you can help with.

I am setting the DataSource of a DataGrid to be a DataView. I am sorting
the DataView by various fields which include a Date.

When I create a new row in the DataGrid and set the date to me within the
current sort range, the newly created row "jumps" to its correct position
in the grid. This obviously makes sense because it is following the sort
rule.

However, I would like to be able to achive the following:

(1) Display the DataView in the DataGrid initially sorted using the rules
specified.
(2) New rows can be added to the DataGrid BUT no sorting will occur.
(3) If a button is pressed, then the grid will re-sort using the sort rule
specified initially.

I don't know if it makes any difference but the DataView I am using is
global to the form.

I hope somebody can help.

Many thanks in advance

G

Apr 2 '06 #2
Hi Cor

I'm using VS 2003.

I think I understand what you mean, however, just to clarify, are you saying
what I want to do is impossible?

G

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:en******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

Be aware that this acts probably different in versions 2002/2003 and 2005

The dataview should be dynamic but is that not always in 2002/2003

As well is there a bug that put a newly added datarow at the end in some
situations of the datagrid. Exactly in fact as you want.

But making use of that bug is not the best thing to do.

I hope that you understand because of this that your question is difficult
answer

Cor

"G .Net" <no********@ema il.com> schreef in bericht
news:ue******** ************@pi pex.net...
Hi

I have a question which I hope you can help with.

I am setting the DataSource of a DataGrid to be a DataView. I am sorting
the DataView by various fields which include a Date.

When I create a new row in the DataGrid and set the date to me within the
current sort range, the newly created row "jumps" to its correct position
in the grid. This obviously makes sense because it is following the sort
rule.

However, I would like to be able to achive the following:

(1) Display the DataView in the DataGrid initially sorted using the rules
specified.
(2) New rows can be added to the DataGrid BUT no sorting will occur.
(3) If a button is pressed, then the grid will re-sort using the sort
rule specified initially.

I don't know if it makes any difference but the DataView I am using is
global to the form.

I hope somebody can help.

Many thanks in advance

G


Apr 2 '06 #3
G,

You can forever add an extra column and set in that a default value.

When you add it you set this column to a vale which is higer than the
default value.
You take that your dataview as first sort key.
If the button is pressed than you can change that column in the last datarow
in the datatable again to the default value..

The last row is datatable.rows( datatable.rowco unt-1)

Not that difficult in my opinion and as far as I can see now will that work
forever.

I hope this helps,

Cor

"G .Net" <no********@ema il.com> schreef in bericht
news:op******** ************@pi pex.net...
Hi Cor

I'm using VS 2003.

I think I understand what you mean, however, just to clarify, are you
saying what I want to do is impossible?

G

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:en******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

Be aware that this acts probably different in versions 2002/2003 and 2005

The dataview should be dynamic but is that not always in 2002/2003

As well is there a bug that put a newly added datarow at the end in some
situations of the datagrid. Exactly in fact as you want.

But making use of that bug is not the best thing to do.

I hope that you understand because of this that your question is
difficult answer

Cor

"G .Net" <no********@ema il.com> schreef in bericht
news:ue******** ************@pi pex.net...
Hi

I have a question which I hope you can help with.

I am setting the DataSource of a DataGrid to be a DataView. I am sorting
the DataView by various fields which include a Date.

When I create a new row in the DataGrid and set the date to me within
the current sort range, the newly created row "jumps" to its correct
position in the grid. This obviously makes sense because it is following
the sort rule.

However, I would like to be able to achive the following:

(1) Display the DataView in the DataGrid initially sorted using the
rules specified.
(2) New rows can be added to the DataGrid BUT no sorting will occur.
(3) If a button is pressed, then the grid will re-sort using the sort
rule specified initially.

I don't know if it makes any difference but the DataView I am using is
global to the form.

I hope somebody can help.

Many thanks in advance

G



Apr 2 '06 #4
Thanks Cor

G

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uS******** ******@TK2MSFTN GP12.phx.gbl...
G,

You can forever add an extra column and set in that a default value.

When you add it you set this column to a vale which is higer than the
default value.
You take that your dataview as first sort key.
If the button is pressed than you can change that column in the last
datarow in the datatable again to the default value..

The last row is datatable.rows( datatable.rowco unt-1)

Not that difficult in my opinion and as far as I can see now will that
work forever.

I hope this helps,

Cor

"G .Net" <no********@ema il.com> schreef in bericht
news:op******** ************@pi pex.net...
Hi Cor

I'm using VS 2003.

I think I understand what you mean, however, just to clarify, are you
saying what I want to do is impossible?

G

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:en******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

Be aware that this acts probably different in versions 2002/2003 and
2005

The dataview should be dynamic but is that not always in 2002/2003

As well is there a bug that put a newly added datarow at the end in some
situations of the datagrid. Exactly in fact as you want.

But making use of that bug is not the best thing to do.

I hope that you understand because of this that your question is
difficult answer

Cor

"G .Net" <no********@ema il.com> schreef in bericht
news:ue******** ************@pi pex.net...
Hi

I have a question which I hope you can help with.

I am setting the DataSource of a DataGrid to be a DataView. I am
sorting the DataView by various fields which include a Date.

When I create a new row in the DataGrid and set the date to me within
the current sort range, the newly created row "jumps" to its correct
position in the grid. This obviously makes sense because it is
following the sort rule.

However, I would like to be able to achive the following:

(1) Display the DataView in the DataGrid initially sorted using the
rules specified.
(2) New rows can be added to the DataGrid BUT no sorting will occur.
(3) If a button is pressed, then the grid will re-sort using the sort
rule specified initially.

I don't know if it makes any difference but the DataView I am using is
global to the form.

I hope somebody can help.

Many thanks in advance

G



Apr 3 '06 #5

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

Similar topics

4
2841
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the form/grid first opens up and the grid is immediately sorted the TB don't reflect the sorted data of the First row of the grid. Note: Initially the black grid indicator arrow points to the first row. If the user choses another row and then sorts...
0
1384
by: Robert Brinson | last post by:
Hello all! I'm running .NET Framework 1.1 using VS.NET 2003. I've got a mystery with a DataGrid. Below is the definition of the DataGrid from my aspx page: </asp:datagrid><asp:datagrid id="dgDetails" Runat="server" Width="100%" Visible="False" AllowSorting="True" CellPadding="1" CellSpacing="0" AutoGenerateColumns="False" OnSortCommand="SortDetails"> <ItemStyle Font-Size="XX-Small" Font-Names="Tahoma"></ItemStyle> <HeaderStyle...
2
2260
by: enak | last post by:
I can not get my datagrid to page. I have a datagrid that I can sort 2 of the columns. This works great. I added paging and when I display the dg it shows 5 pages. (I am showing page numbers at the bottom of the dg.) When I click on the pages nothing happens until I get to the last page. Then and only then is the last page displayed. If I go back through the pages the second to last page displayes the first page again.
7
2465
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 Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here
1
2350
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 page. i.e. If I have: IntegerValue StringValue CurrencyValue 0 Item 0 0 1 Item 1 1.23
5
2790
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
2
4049
by: shuckjunkmail | last post by:
It was suggested that I re-submit this question as a new post rather than adding onto an old and unanswered post. The basic problem has to do with the .NET datagrid and sorting. I am having trouble getting the correct row of data from the datagrid immediately after re-sorting the datagrid. I am using the dataview for accessing the data and am using the following code as previously mentioned in a different post: Dim bm As...
2
3672
by: Joey | last post by:
I have an asp.net 1.1 C# web application with a datagrid. I set the datagrid's "AllowSorting" property to "True". Then I created a sort function for it by selecting the datagrid in the designer, then the Event button in the Properties window, and then double clicking in the "SortCommand" box. Then in the function that was created for me, I entered my code. Now, the datagrid will not sort. I planted a breakpoint on the first line of code...
0
1335
by: rn5a | last post by:
A DataGrid control displays records from a SQL Server 2005 DB table. The AllowSorting property of the DataGrid has been set to True & the SortExpressions of the BoundColumns have been set to the different columns so that users can sort the DataGrid by clicking the headers in the DataGrid. The DataGrid can be sorted using all the headers in the DataGrid except for the first column header. <asp:DataGrid ID="dg1" AllowSorting="true"...
0
2088
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 help........pls urgent ========================================================= <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.