I am experiencing a slight problem. I loaded information into a data table. But for some reason after I leave the sub routine that populated the table, everything is lost. So when I goto a button click event and try to use the information that is in the table.. it basically gone.. I get "" in all the cells. Anyone have any ideals why this would happen or any suggestions would be helpful.
'some code
dim dt2 As New DataTable
'sub that populates the table
dt.Columns.Add("Part Number", GetType(TemplateColumn))
dt.Columns.Add("TempPart", GetType(String))
dt.Columns.Add("Product Type", GetType(TemplateColumn))
dt.Columns.Add("TempType", GetType(String))
dt.Columns.Add("Price", GetType(String))
dt.Columns.Add("Description", GetType(TemplateColumn))
dt.Columns.Add("Add to cart", GetType(TemplateColumn))
dt.Columns.Add("Weight", GetType(String))
For Each row In ds.Tables(0).Rows
Dim price As String
price = ds.Tables(0).Rows(i).Item(3)
price = CType(price, Decimal)
price = FormatNumber(price, 2)
row = dt.NewRow
row.Item(0) = ""
row.Item(1) = ds.Tables(0).Rows(i).Item(4)
row.Item(2) = ""
row.Item(3) = ds.Tables(0).Rows(i).Item(1)
row.Item(4) = price
row.Item(5) = ""
dt.Rows.Add(row)
i += 1
Next
Datagrid2.DataSource = dt
Datagrid2.DataBind()
When I click on a button after binding the information to a datagrid.. I check the row count in for data table and it returns count = 0
-mike
'some code
dim dt2 As New DataTable
'sub that populates the table
dt.Columns.Add("Part Number", GetType(TemplateColumn))
dt.Columns.Add("TempPart", GetType(String))
dt.Columns.Add("Product Type", GetType(TemplateColumn))
dt.Columns.Add("TempType", GetType(String))
dt.Columns.Add("Price", GetType(String))
dt.Columns.Add("Description", GetType(TemplateColumn))
dt.Columns.Add("Add to cart", GetType(TemplateColumn))
dt.Columns.Add("Weight", GetType(String))
For Each row In ds.Tables(0).Rows
Dim price As String
price = ds.Tables(0).Rows(i).Item(3)
price = CType(price, Decimal)
price = FormatNumber(price, 2)
row = dt.NewRow
row.Item(0) = ""
row.Item(1) = ds.Tables(0).Rows(i).Item(4)
row.Item(2) = ""
row.Item(3) = ds.Tables(0).Rows(i).Item(1)
row.Item(4) = price
row.Item(5) = ""
dt.Rows.Add(row)
i += 1
Next
Datagrid2.DataSource = dt
Datagrid2.DataBind()
When I click on a button after binding the information to a datagrid.. I check the row count in for data table and it returns count = 0
-mike