J
J
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
ip()
If Not IsPostBack Then
DataGrid1.DataBind()
End If
End Sub
Sub ip()
Dim newrow As DataRow
SqlConnection1.Open()
SqlCommand1.Parameters("@members").Value = "1007,4200,999"
daTest.SelectCommand = SqlCommand1
daTest.Fill(dsTest, "TestTable")
Dim dvTest As New DataView(dsTest.Tables("TestTable"), "", "",
DataViewRowState.CurrentRows)
DataGrid1.DataSource = dvTest
newrow = dsTest.Tables("TestTable").NewRow
newrow(0) = "1"
newrow(1) = "Jason"
newrow(2) = "1"
dsTest.Tables("TestTable").Rows.Add(newrow)
dsTest.AcceptChanges()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim newrow As DataRow
newrow = dsTest.Tables("TestTable").NewRow
newrow(0) = "2"
newrow(1) = "Jason"
newrow(2) = "1"
dsTest.Tables("TestTable").Rows.Add(newrow)
dsTest.AcceptChanges()
DataGrid1.DataBind()
End Sub
When I click the button, I would have thought that the datagrid would keep
increasing with the values "2,", "Jason", "1", but it doesn't.
I believe I have what is called a disconnected dataset, and I need the user
to work on a dataset before they post the final values to the server, hence
why I'm not using a SQL Adapter.
Can someone PLEASE explain why the above won't work, and how to work with
disconnected datasets.
TIA
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
ip()
If Not IsPostBack Then
DataGrid1.DataBind()
End If
End Sub
Sub ip()
Dim newrow As DataRow
SqlConnection1.Open()
SqlCommand1.Parameters("@members").Value = "1007,4200,999"
daTest.SelectCommand = SqlCommand1
daTest.Fill(dsTest, "TestTable")
Dim dvTest As New DataView(dsTest.Tables("TestTable"), "", "",
DataViewRowState.CurrentRows)
DataGrid1.DataSource = dvTest
newrow = dsTest.Tables("TestTable").NewRow
newrow(0) = "1"
newrow(1) = "Jason"
newrow(2) = "1"
dsTest.Tables("TestTable").Rows.Add(newrow)
dsTest.AcceptChanges()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim newrow As DataRow
newrow = dsTest.Tables("TestTable").NewRow
newrow(0) = "2"
newrow(1) = "Jason"
newrow(2) = "1"
dsTest.Tables("TestTable").Rows.Add(newrow)
dsTest.AcceptChanges()
DataGrid1.DataBind()
End Sub
When I click the button, I would have thought that the datagrid would keep
increasing with the values "2,", "Jason", "1", but it doesn't.
I believe I have what is called a disconnected dataset, and I need the user
to work on a dataset before they post the final values to the server, hence
why I'm not using a SQL Adapter.
Can someone PLEASE explain why the above won't work, and how to work with
disconnected datasets.
TIA