Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataview not saving update to Dataset.

Status
Not open for further replies.

NoCoolHandle

Programmer
Apr 10, 2003
2,321
US
Hi.

I have a webpage that reads an xml file into a dataset. This dataset can then be filtered by adding a dataview to the dataset and then setting the rowfilter property.

I have set the dataview.allowupdates=true.

When a textbox's text is changed, the change is written to the dataview.

When I save the underlying dataset back to the hard drive though, the changes are lost.

I have tried calling the datatables "acceptChanges" method, but this fails also...

Any clues would be appreciated.

code below

Rob


Code:
        If fName = "" Then fName = DropDownList1.SelectedValue

        Dim t As TextBox = sender
        Dim iR As Integer = CInt(Val(t.ID.Replace("lbl", "")))
        Dim iC As Integer = t.ID.Substring(t.ID.LastIndexOf("_") + 1)
        Dim ds As New DataSet
        ds.ReadXml(fName)
        'WE need to run filters.
        Dim dv As New DataView(ds.Tables(0))
        dv.AllowEdit = True

        If cmbFields.SelectedValue <> "" And txtFilter.Text.Trim <> "" Then
            dv.RowFilter = cmbFields.SelectedValue & " like '%" & txtFilter.Text & "'"
        End If
        Try
[green] 'iR is the RowNumber and iC is the column number. This is stored in the textbox's id when it is generated.[/green]            
            dv.Item(iR)(iC) = t.Text
        Catch
        End Try

        RunAsAdmin()
        ds.Tables(0).AcceptChanges()
        
        ds.WriteXml(fName)
        dv.Dispose()
 
Hmmmm....
I was having a bizzare incidence of event precidence.

A textbox was sending a change event when the filter was being applied.

For some reason it is working fine now.

(the page dynamicly builds a list of all xml files in a directory, it then creates an editor based on the contents of the selected file.. ANytime a textbox's contets change, it fires an update, which inturn saves the change back to the dataset(and xml file))

If you are interested in the code..

look at
PS The site is a test ground and should be ignored as a source of content for anything except this sort of thing.

any fix's you make, please email me back. Any address lynchtek.com gets to me. Just include something about "xmleditor" fix..

Otherwise enjoy it and just give it away - if you sell it.. Send my kids some pocket money :)

.

TIA

Rob

(PS it will take about 30 min to add this to the site..)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top