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

Having trouble adding a row to a dataview :(

Hi all,

Basic issue. I'm handed a dataview from a function, that's based on a
filtered table. The dataview is then assigned to a combobox for
display. I want to insert a new row into this dataview (the "none
selected" option), and have it at the top of the rowset.

I'm confused about the container-hierarchy of the dataview. Can
someone plz show me how inserting a row at the top of a dataview would
go?

Thanks!

cdj
Sep 12 '08 #1
1 916

"sherifffruitfly" wrote:
Hi all,

Basic issue. I'm handed a dataview from a function, that's based on a
filtered table. The dataview is then assigned to a combobox for
display. I want to insert a new row into this dataview (the "none
selected" option), and have it at the top of the rowset.

I'm confused about the container-hierarchy of the dataview. Can
someone plz show me how inserting a row at the top of a dataview would
go?

Thanks!

cdj
Hi,

I'm afraid you will have to add a DataRowView to the DataView and sort the
data so the "none selected"-row appears topmost. If this acceptable simply
use the DataView.AddNew method.

DataView dv = GetView();
DataRowView drv = dv.AddNew();
drv[0] = "none selected";
drv[1] = 0;
drv.EndEdit();
dv.Sort = "Value ASC";

Column 2 is "Value" containing id numbers so sorting by id will put this row
topmost. Unless you call EndEdit() the row won't get sorted.
--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 15 '08 #2

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

Similar topics

1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
10
by: Eric Petruzzelli | last post by:
If I fill my dataset and there is no data. The dataset is still created with zero rows (all columns are there). When I add my first row using the script below, it takes over 2 seconds to add??? If...
1
by: amber | last post by:
Hi there, I have a dataview that is populated from a dataset, from SQL Server. I want to cycle through the dataview, adding "1)" then "2)" etc in front of each string. I can't figure out the...
6
by: DraguVaso | last post by:
Hi, I have a ComboBox of +- 15.000 items in it, via a DataSource. On Top of the Items-list, I want to add some values, based on a user choise (via a filter on the DataSource). Does anybody know...
0
by: Shravan | last post by:
Hi, I have a extended datagrid, in which I am setting values at a given cell in the grid using grid = val; The grid has NewRow creation set to false But sometimes setting value at a...
1
by: Mel Weaver | last post by:
Hi, I'm using a typed dataset and adding a new row to dataview. DataRowView newDRV = catView.AddNew(); newDRV = acf.categoryTextBox.Text; newDRV.EndEdit(); The row is added. My problem is I...
1
by: Vee Kay | last post by:
hi, this is my first post here. i'm in desparate need of resources for VC++.NET; the code in MSDN is only directed for VB/C#.. for C++ its very few and faar in between!! the web is no good...
16
by: scorpion53061 | last post by:
Well as some of you know I was using a tab control for a project I was building for my boss. Today he tells me that he wants: When he switches tabs to be able to switch back and see whatever...
5
by: Maria Anthonsen | last post by:
I have filled a datagrid with data from a dataset. The dataset was filled with a dataadapter - and I used the wizard to create insert, update, delete commands. I would like to prevent the user...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.