I'm struggling with the postback on .NET forms. I'm obviously not understanding something.
In the declarations of my page I have this:
In the form load function I have this code:
I have a BindPricing() function that populates my datagrid called grdPricing.
The problem is, I do a lot of calculations on the grid. If a user changes the value inside of a textbox, it needs to update other things on the grid. The textbox calls CalcTotals(). But when I try to access the dataset insde of CalcTotals, that I made public originally (dsPricing) it says it's "Nothing". So I rebuild the dataset, which in turns wipes out everything the user just changed. I know I don't want to rebuild this dataset on the fly.
Why isn't my dataset staying public? Why does it disappear? This is a huge page of code, so I have not posted everything. Maybe there is something else I'm doing that's wiping out the dataset.
In the declarations of my page I have this:
Code:
Dim dsPricing As DataSet
Code:
If Not Page.IsPostBack Then
If dsPricing Is Nothing Then
If blPricingFlag = False Then
dsPricing = oPricing.GetPricingGridByBTN(strBillToNum, dtExpirationDate)
Else
dsPricing = oPricing.GetPricingGridByContractID(iContractID)
End If
End If
BindPricing()
End If
I have a BindPricing() function that populates my datagrid called grdPricing.
Code:
Public Sub BindPricing()
'Bind the grid to the sorted data view.
Dim dv As New DataView(dsPricing.Tables(0))
dv.Sort = _sSort
grdPricing.DataSource = dv
grdPricing.DataBind()
End Sub
The problem is, I do a lot of calculations on the grid. If a user changes the value inside of a textbox, it needs to update other things on the grid. The textbox calls CalcTotals(). But when I try to access the dataset insde of CalcTotals, that I made public originally (dsPricing) it says it's "Nothing". So I rebuild the dataset, which in turns wipes out everything the user just changed. I know I don't want to rebuild this dataset on the fly.
Why isn't my dataset staying public? Why does it disappear? This is a huge page of code, so I have not posted everything. Maybe there is something else I'm doing that's wiping out the dataset.