Hi all
Im trying pass data from a dataset into a html table ...but keep Getting the following exception !
Value of type 'System.Data.Datarow' cannot be converted to 'System.Web.UI.Htmlcontrols.HtmltableRow'
when adding rows to Table1 .....
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyDataset As DataSet
Dim MyTable As New DataTable
Dim i, numrows As Integer
Dim sqlstr As String
' Fill a DataSet with data returned from the database.
MyDataset = New DataSet
MyDataset.ReadXml(Server.MapPath("XML/Kassestrimmel.xml"))
' Create a new DataTable object and assign to it
' the new table in the Tables collection.
MyTable = MyDataset.Tables(0)
' Find how many rows are in the Rows collection
' of the new DataTable object.
numrows = MyTable.Rows.Count
If numrows = 0 Then
Exit Sub
Else
For i = 0 To numrows - 1
' Print the values of the columns in the Columns
' collection for each row.
Table2.Rows.Add(MyTable.Rows(i))'---------Value of type 'System.Data.Datarow' cannot be converted to 'System.Web.UI.Htmlcontrols.HtmltableRow'
Next i
End If
End Sub
hope someone got an idea ?
thanksA Datarow isn't an Htmltablerow. The simplest thing to do here would be to create HtmlTableCells for each field in the Datarow and generate an Htmltablerow that way.
Im trying pass data from a dataset into a html table ...but keep Getting the following exception !
Value of type 'System.Data.Datarow' cannot be converted to 'System.Web.UI.Htmlcontrols.HtmltableRow'
when adding rows to Table1 .....
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyDataset As DataSet
Dim MyTable As New DataTable
Dim i, numrows As Integer
Dim sqlstr As String
' Fill a DataSet with data returned from the database.
MyDataset = New DataSet
MyDataset.ReadXml(Server.MapPath("XML/Kassestrimmel.xml"))
' Create a new DataTable object and assign to it
' the new table in the Tables collection.
MyTable = MyDataset.Tables(0)
' Find how many rows are in the Rows collection
' of the new DataTable object.
numrows = MyTable.Rows.Count
If numrows = 0 Then
Exit Sub
Else
For i = 0 To numrows - 1
' Print the values of the columns in the Columns
' collection for each row.
Table2.Rows.Add(MyTable.Rows(i))'---------Value of type 'System.Data.Datarow' cannot be converted to 'System.Web.UI.Htmlcontrols.HtmltableRow'
Next i
End If
End Sub
hope someone got an idea ?
thanksA Datarow isn't an Htmltablerow. The simplest thing to do here would be to create HtmlTableCells for each field in the Datarow and generate an Htmltablerow that way.