473,804 Members | 3,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: Dataview and a grid

Hi

Can anybody help with the following?

I have a datagrid which has a dataview of a datatable in a dataset as a
view. I can add new rows to the grid, however I'm puzzled as to how to pass
these changes to the database i.e. if I simple use Update on the table, the
rows I've added to the grid aren't written to the database.

Can anybody help?

Thanks in advance

Geoff
Feb 21 '06 #1
4 1231
Geoff,

Mostly is the point that there is only an endcurrentedit needed direct
before your update statement.
BindingContext( "dv").EndCurren tEdit()

Something like that where the dv stends for your datasource

I hope this helps

Cor
"G .Net" <no********@ema il.com> schreef in bericht
news:Ad******** *************** *******@pipex.n et...
Hi

Can anybody help with the following?

I have a datagrid which has a dataview of a datatable in a dataset as a
view. I can add new rows to the grid, however I'm puzzled as to how to
pass these changes to the database i.e. if I simple use Update on the
table, the rows I've added to the grid aren't written to the database.

Can anybody help?

Thanks in advance

Geoff

Feb 21 '06 #2
Hi Cor

Thanks for your suggestion. I think I may have found a solution to my
problem by an alternative method. However, I hope you may be able to help
with a related matter.

The DataView I'm using as the datasource to the grid has a filter. The
condition for the filter is not one of the fields being displayed. So, for
example, if the grid displays two columns A and B, the value in column C
(which is not displayed) is the filter condition.

The problem I have is that I add data to the grid and obviously because the
value in C is not being inputted in the grid, the row immediately disappears
after inputting data. How can I write a value into C as soon as the user
starts adding data to the row in the grid so it doesn't disappear i.e. the
filter condition will be satisfied.

Thanks in advance

Geoff

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Ox******** ******@TK2MSFTN GP10.phx.gbl...
Geoff,

Mostly is the point that there is only an endcurrentedit needed direct
before your update statement.
BindingContext( "dv").EndCurren tEdit()

Something like that where the dv stends for your datasource

I hope this helps

Cor
"G .Net" <no********@ema il.com> schreef in bericht
news:Ad******** *************** *******@pipex.n et...
Hi

Can anybody help with the following?

I have a datagrid which has a dataview of a datatable in a dataset as a
view. I can add new rows to the grid, however I'm puzzled as to how to
pass these changes to the database i.e. if I simple use Update on the
table, the rows I've added to the grid aren't written to the database.

Can anybody help?

Thanks in advance

Geoff


Feb 21 '06 #3
Georg,

Better is not to extend questions with new questions, maybe is there
somebody who knows the answer direct. Because of what you ask, I use a
button to add on a screen.

I thought that there was a solution, so maybe it is better to make a new
message.

Cor
Feb 22 '06 #4
If AllowNew is true you can use the AddNew method of the DataView to create a new DataRowView. Note that a new row is not actually added to the underlying DataTable until the EndEdit method of the DataRowView is called. If the CancelEdit method of the DataRowView is called, the new row is discarded.

Dim custTable As DataTable = custDS.Tables(" TBL1")
Dim custView As DataView = custTable.Defau ltView

custView.AllowD elete = False

Dim newDRV As DataRowView = custView.AddNew ()
newDRV("Field1" ) = "ABCDE"
newDRV("Field2" ) = "ABCDE Descr"
newDRV.EndEdit( )
As an alternative download IdeaBlade’s DevForce Express and use that for ORM (I don’t work for them – but use it extensively)

Apr 1 '06 #5

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

Similar topics

9
2589
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in Window2K server"). First of all, here are the two methods I have used in order to apply the sorting property to the DataView 1. Simply defining the sort order and colum DataView...
4
1540
by: Martin Schmid | last post by:
I am trying to implement a DataView for a DataGrid so I can sort at runtime by clicking on column headers. My initial page load works... it displays the data However, when I click a column heading at run time, the data doesn't sort as expected, in fact, the DataGrid becomes empty, all I see are column headings: SqlConnection sqlConnection; protected System.Web.UI.WebControls.DataGrid DataGrid1; protected ProjContMan.dsProjByDate...
2
4889
by: Hananiel | last post by:
Using Dataview as a datasource for datagrid works fine while viewing. When I make a new row, by calling dataview.AddNew(), it removes all the rows in the grid. Anyone know whats going on? In any case how would you bind two different grids to the same table, can we filter the rows in the grid? Thanks, Hananiel
0
3711
by: VM | last post by:
In my Windows application, I load an ascii file into a tableX and set the datagrid.DataSource = tableX. The problem begins when I try to retrieve the data from the grid in order to process the changes made by the user. In this form, the user has the choice of modifying the original data in the grid (wich comes from tableX as DataSource) or do a filter in the datagrid (I use a dataview) and then make changes. If the user makes any changes...
13
2120
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is the confusion......... I thought that the DataView is the view from the dataset, but it seems that the dataview has the records that are in the datagrid, because everytime I search for a record that I know is NOT in the dataset, it finds it. I...
4
2621
by: Aaron Smith | last post by:
Dim dv As DataView = New DataView(FacilitiesDS1.Facilities, "", "ID ASC", DataViewRowState.CurrentRows) Dim iPos As Integer = dv.Find(dr.Item("ID")) Me.BindingContext(FacilitiesDS1, "Facilities").Position = iPos That is the code.. dr is DataRow. If dr.Item("ID") = 3, the find will return position 0, which it should have been 1, and if the ID = 2, it will return 1, which should have been 0.. The DA has a connection string that sorts it...
2
10015
by: HansP | last post by:
Hi, I am really in a deadlock with this problem. In my VS2005 C# handheld application, I have a grid with Workorders. Another grid (child) are the ACTIONS, performed for each workorder. Both grids have Dataviews as DataSource. The child grid, filtered with RowFilter in the DataView works fine.
3
1086
by: G .Net | last post by:
Hi I'm hoping that somebody can help me with the following: I have a DataTable which I'm displaying in a DataGrid. I am changing values in this grid which need to be passed back to the DataTable and then back to the database source. In the grid, I sometimes only want to show some of the rows i.e. I filter it. I do this by using a DataView to the DataTable and then filtering the
7
1744
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2 for windows applciation. I have a form with 1 datagrids whose datasource comes from 2 dataview that are based on 2 dataset datatables(depends on the stat of the application then one of the dataview will be selected as datasource for the grid). Both dataview have only 2 columns but one of the columns name is different. Depending on the state of the application, I would need to change the datasource to be...
0
9576
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
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
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...
1
7613
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
6847
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
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 we have to send another system
2
3813
muto222
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.