I lost the state of myDataSet.HasChanges between diferents events

E

Evelin

Hi, I use ASP.NET and my problem is I´ve two buttons, a dataSet, a
dataGrid and a sqlDataAdpater, I use
sqlDataAdapter.fill(dataSet,"dbTable"), then when when the user press
the first button, I add a row to a dataSet, but not to the dataBase.
This is my code:

Public Sub Button1_Click(byBal sender As System.Object, byVal e As
System.EventArgs) Handles Button1.Click
dim myRow as dataRow

myRow = dataSet.Tables("dbTable").newRow
myRow("id")=1
myRow("description")="Trade Company"
dataSet.Tables ("dbTable").Rows.Add(myRow)
dataGrid.dataBind()

End Sub

Public Sub Button2_Click(byBal sender As System.Object, byVal e As
System.EventArgs) Handles Button2.Click
dim xDataSet As dataSet
dim myRow as dataRow

If dataSet.HasChanges Then
xDataSet = dataSet.getChanges(DataRowState.Added)
xDataSet.Tables("dbTable").newRow()

for each myRow in xDataSet.tables("dbTable").Rows
'Here I call a Store Procedure with sqlDataReader and saved the
register in dataBase's Table

next
End If
End Sub

Then, when the user press button1; after add the row the
dataSetdataSet.HasChanges = TRUE , then the user press the Button2 and
the datataSet.HasChanges =FALSE,so the dataSet lost its state, I think
it happens when the WebForm return to the user...
In fact, I need put the button2's code in another webForm....

Thanks!!!!
Evelin

Sorry, but I don´t speak english very well as you saw....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top