B
buran
Dear ASP.NET Programmers,
Here's my problem: I have a page (as usual
, in which I'm going to display invoices in a repeater control. I am binding data to the repeater control (ID: repHospCosts) without any problems. I have also a button on the page, I am going to add a new datarow programmatically and display it when pressed. Unfortunately, I cannot refer to the dataset in the event handler of the button (or at least I think so). I get the following error: Object reference not set to an instance of an object. drow = dtable.NewRow
Below is the code:
Dim dtable As DataTable
Dim drow As DataRow
If Not Page.IsPostBack Then
LoadHospCosts()
End If
Sub LoadHospCosts()
strSql = "spGetHospAmounts"
myCommand.CommandText = strSql
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.Clear()
myCommand.Parameters.Add("@ourFileNo", Session("selectedFileNumber"))
myDataAdapter.Fill(myDataSet, "HospCosts")
repHospCosts.DataSource = myDataSet
repHospCosts.DataMember = "HospCosts"
repHospCosts.DataBind()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
dtable = myDataSet.Tables("HospCosts")
drow = dtable.NewRow
drow("SPName") = "Buran"
drow("InvoiceAmount") = 100
dtable.Rows.Add(drow)
dtable.AcceptChanges()
Dim subTotal As Double
For Each drow In dtable.Rows
subTotal += drow.Item("InvoiceAmount")
Next
lblSubTotal.Text = Format(subTotal, "n")
End Sub
I need any help I can get, thanks in advance...
Buran
Here's my problem: I have a page (as usual
Below is the code:
Dim dtable As DataTable
Dim drow As DataRow
If Not Page.IsPostBack Then
LoadHospCosts()
End If
Sub LoadHospCosts()
strSql = "spGetHospAmounts"
myCommand.CommandText = strSql
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.Clear()
myCommand.Parameters.Add("@ourFileNo", Session("selectedFileNumber"))
myDataAdapter.Fill(myDataSet, "HospCosts")
repHospCosts.DataSource = myDataSet
repHospCosts.DataMember = "HospCosts"
repHospCosts.DataBind()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
dtable = myDataSet.Tables("HospCosts")
drow = dtable.NewRow
drow("SPName") = "Buran"
drow("InvoiceAmount") = 100
dtable.Rows.Add(drow)
dtable.AcceptChanges()
Dim subTotal As Double
For Each drow In dtable.Rows
subTotal += drow.Item("InvoiceAmount")
Next
lblSubTotal.Text = Format(subTotal, "n")
End Sub
I need any help I can get, thanks in advance...
Buran