Home All Groups Group Topic Archive Search About

Q: Dataview and a grid

Author
21 Feb 2006 2:19 PM
G .Net
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

Author
21 Feb 2006 2:36 PM
Cor Ligthert [MVP]
Geoff,

Mostly is the point that there is only an endcurrentedit needed direct
before your update statement.


     BindingContext("dv").EndCurrentEdit()

Something like that where the dv stends for your datasource

I hope this helps

Cor


Show quoteHide quote
"G .Net" <nodamnspam@email.com> schreef in bericht
news:AdOdnSyUIfP_v2benZ2dnUVZ8t2dnZ2d@pipex.net...
> 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
>
Author
21 Feb 2006 2:50 PM
G .Net
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

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:Oxl$5PvNGHA.2176@TK2MSFTNGP10.phx.gbl...
> Geoff,
>
> Mostly is the point that there is only an endcurrentedit needed direct
> before your update statement.
>
>
>     BindingContext("dv").EndCurrentEdit()
>
> Something like that where the dv stends for your datasource
>
> I hope this helps
>
> Cor
>
>
> "G .Net" <nodamnspam@email.com> schreef in bericht
> news:AdOdnSyUIfP_v2benZ2dnUVZ8t2dnZ2d@pipex.net...
>> 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
>>
>
>
Author
22 Feb 2006 6:50 AM
Cor Ligthert [MVP]
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
Author
1 Apr 2006 8:05 AM
mikeinthemud
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.DefaultView

        custView.AllowDelete = 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)