J
Jordan
I'm trying to incorporate a data tier into my asp.net web application (add,
update, delete, etc), as opposed to using spaghetti code.
So far my "getter" class, "CabinetSpec.vb", has Update, Add, and Delete
methods that
work perfectly. However, I am having problems with my "List" function which
returns a dataset that gets bound to a listbox on my webform.
Everytime I add, update or delete a CabinetSpec on the webform, the ListBox
containing the list of CabinetSpecs updates itself using this function:
-------------------------------------------------------
Public Class CabinetSpec
Public Function List() As DataSet
'return a list of RowIDs & Descriptions
mstrSQL = "SELECT CabinetSpecID, Description FROM CabinetSpecs ORDER BY
Description"
Dim ds As New DataSet
Try
Connect()
Dim da As New SqlDataAdapter(mstrSQL, objConnection)
da.Fill(ds, "CabinetSpecs")
Catch ex As Exception
Throw ex
Finally
Disconnect()
End Try
Return ds
End Function
-------------------------------------------------------
Then my webform binds the data to the ListView here:
-------------------------------------------------------
CabinetSpec.aspx
Private Sub Fill_lstSpecs()
Try
Dim CS As New CabinetSpec
With lstSpecs
.SelectedIndex = -1
.DataSource = CS.List.Tables(0).DefaultView
.DataTextField = "Description"
.DataValueField = "CabinetSpecID"
.DataBind()
End With
Catch ex As Exception
lblError.Text = ex.Message
End Try
End Sub
-------------------------------------------------------
This partially works. I can see the ListBox update itself everytime I Add,
Update
or Delete a record. The problem occurs when I leave the page and return -
for some reason when
the page loads Fill_lstSpecs() the ListBox no longer shows the most recent
dataset. For example, I add a new CabinetSpec Description "test1".
Fill_lstSpecs() fires and the ListBox now shows "test1". I leave the page
and come back, Fill_lstSpecs() fires again, but now "test1" doesn't appear.
Restarting the site and loading the page will then show the updated dataset,
so I guess this is a scope problem?
Any diagnosis would be appreciated.
Thanks,
Jordan
update, delete, etc), as opposed to using spaghetti code.
So far my "getter" class, "CabinetSpec.vb", has Update, Add, and Delete
methods that
work perfectly. However, I am having problems with my "List" function which
returns a dataset that gets bound to a listbox on my webform.
Everytime I add, update or delete a CabinetSpec on the webform, the ListBox
containing the list of CabinetSpecs updates itself using this function:
-------------------------------------------------------
Public Class CabinetSpec
Public Function List() As DataSet
'return a list of RowIDs & Descriptions
mstrSQL = "SELECT CabinetSpecID, Description FROM CabinetSpecs ORDER BY
Description"
Dim ds As New DataSet
Try
Connect()
Dim da As New SqlDataAdapter(mstrSQL, objConnection)
da.Fill(ds, "CabinetSpecs")
Catch ex As Exception
Throw ex
Finally
Disconnect()
End Try
Return ds
End Function
-------------------------------------------------------
Then my webform binds the data to the ListView here:
-------------------------------------------------------
CabinetSpec.aspx
Private Sub Fill_lstSpecs()
Try
Dim CS As New CabinetSpec
With lstSpecs
.SelectedIndex = -1
.DataSource = CS.List.Tables(0).DefaultView
.DataTextField = "Description"
.DataValueField = "CabinetSpecID"
.DataBind()
End With
Catch ex As Exception
lblError.Text = ex.Message
End Try
End Sub
-------------------------------------------------------
This partially works. I can see the ListBox update itself everytime I Add,
Update
or Delete a record. The problem occurs when I leave the page and return -
for some reason when
the page loads Fill_lstSpecs() the ListBox no longer shows the most recent
dataset. For example, I add a new CabinetSpec Description "test1".
Fill_lstSpecs() fires and the ListBox now shows "test1". I leave the page
and come back, Fill_lstSpecs() fires again, but now "test1" doesn't appear.
Restarting the site and loading the page will then show the updated dataset,
so I guess this is a scope problem?
Any diagnosis would be appreciated.
Thanks,
Jordan