473,326 Members | 2,099 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.

the position of new added row in datagrid

hi, i have this problem:

at runtime i add rows to a grid (actually to a datatable, that the grid is
binded to)
but the row is added down, after the existing rows and i want it to be the
first shown in grid;

i tried with dataview.sort = "<field> DESC"; but it didn't work
i tried using

dv.ListChanged += new
System.ComponentModel.ListChangedEventHandler(Data View_ListChanged);
protected virtual void DataView_ListChanged(object sender,
System.ComponentModel.ListChangedEventArgs args)
{
if ( (args.ListChangedType == ListChangedType.ItemAdded) |
(args.ListChangedType == ListChangedType.ItemDeleted) )
{
CurrencyManager cm = (CurrencyManager)this.BindingContext[DataSet,
the Relation];
DataView dv = (DataView)cm.List;
dv.Sort = "Position DESC";
cm.refresh();
this.grid.SetDataBinding(null, null);
this.grid.SetDataBinding(DocDataSet, "theRelation");
}

but that didn't worked either

what's wrong?

Thank you,
Daniel
Nov 15 '05 #1
3 1239
In order to counter this and some connected problems in one of my projects, I added a new field which held row positions. When a new row is added, I set the field's value to the least interger amongst the rows which makes appear on top of the datagrid. If you want I could post the code

HTH
fbhca

Nov 15 '05 #2
i thought of this too, but i wanted to use less user-code; what's the .NET
good at, after all? ;)
thanks

"fbhcah" <an*******@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
In order to counter this and some connected problems in one of my projects, I added a new field which held row positions. When a new row is
added, I set the field's value to the least interger amongst the rows which
makes appear on top of the datagrid. If you want I could post the code.
HTH,
fbhcah

Nov 15 '05 #3
..NET is not just a datagrid ;).

It's a whole new WORLD with loads of renovations and revolutions
----- Bamse wrote: ----

i thought of this too, but i wanted to use less user-code; what's the .NE
good at, after all? ;
thank

"fbhcah" <an*******@discussions.microsoft.com> wrote in messag
news:BD**********************************@microsof t.com..
In order to counter this and some connected problems in one of m

projects, I added a new field which held row positions. When a new row i
added, I set the field's value to the least interger amongst the rows whic
makes appear on top of the datagrid. If you want I could post the code
HTH

fbhca

Nov 15 '05 #4

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

Similar topics

2
by: GrantS | last post by:
I am trying to convert the VB.Net code example povided by http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx into C# (ASP.Net)without success. No errors are thrown in the VB...
0
by: Frnak McKenney | last post by:
I have a (small) multi-table database application which allows edits, print reports, and has two scrolling screen displays which show information merged from multiple tables. I'm having trouble...
3
by: tomi | last post by:
Hi I have following problem. I have a datatable filled with some data. Each row holds its ID (column named "Row_ID") DataTable dtTable; I have a datagrid to which I assign this datatable....
3
by: Kenneth | last post by:
Hi, In a webform I have a datagrid in a certain position using gridlayout. <asp:DataGrid id="dgrdSkada" style="Z-INDEX: 107; LEFT: 16px; POSITION: absolute; TOP: 200px" runat="server"...
5
by: JezB | last post by:
There are a few references on the net about how to restore a page's scroll position over a postback. This is a simple one which works for me: eg....
1
by: Tor Inge Rislaa | last post by:
Rearranging the row position in a datagrid Hi I have a datagrid that I fill from a dataset. When the data is displayed in the grid I want the user to be able to move the position of a row. E.g....
1
by: karups | last post by:
Hi I have binded a dataset to my datagrid. Datagrid is present inside a >DIV></DIVtag of specific height. Only 5 records will be visible at a time when i edit the 10th record, the page...
0
by: karups | last post by:
Hi I have binded a dataset to my datagrid. Datagrid is present inside a >DIV></DIVtag of specific height. Only 5 records will be visible at a time when i edit the 10th record, the page...
4
by: Blackbrand | last post by:
I'll start off with what i'm trying to do: i want to search my data programmatically and then jump to the row in the datagrid. My data will almost allways go out of the datagrids bounds so if the...
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
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.