ASP.net manipulating data table bound to GridView
Posted on 2012-08-21
Hi. I am running the following code through a button click. It uses the xSQLTable_Suppliers data table declared at the top of the code and bound using the code further down.
For some reason the data table isn't there. It looks like the variable isn't working. The error that I get is that there is no column called "SupplierName"
Sub Get_Defaults_for_Supplier(ByVal oSupplierName As String)
xSQLTable_Suppliers.DefaultView.RowFilter = "SupplierName='" & SQLConvert(oSupplierName) & "'"
Dim xSQLAdapter_Suppliers As SqlDataAdapter 'declared at top of webform code
Dim xSQLTable_Suppliers As New DataTable
Function Fill_DGV_Suppliers() As Boolean
Dim sSQL As String
sSQL = "Select * From Suppliers"
Dim connection As New SqlConnection(Session("MyVar"))
xSQLAdapter_Suppliers = New SqlDataAdapter(sSQL, connection)
Me.dgvSuppliers.DataSource = xSQLTable_Suppliers
Fill_DGV_Suppliers = True
Catch ex As Exception
Me.lblGeneralError.Text = "Problem loading Suppliers table from SQL " & ex.Message
Fill_DGV_Suppliers = False