Peter Nordberg
asked on
Loop through dataset
Hi,
I'm trying to go through a dataset row by row to do some changes for each row. I tried this code using a treeview checkbox click to activate the procedure:
-------------------------- ---------- ---------- ---------- ---------- ----------
Protected Sub RadTreeView2_NodeCheck(ByV al o As Object, ByVal e As Telerik.WebControls.RadTre eNodeEvent Args) Handles RadTreeView2.NodeCheck
If e.NodeChecked.Value > 1 Then
Dim cImage As New imagesDL
Dim i As Integer
For Each i In cImage.GetImagesByNodeID(e .NodeCheck ed.Value)
Label1.Text = cImage.imageID
Next
End If
Response.Redirect(Request. Url.LocalP ath)
End Sub
-------------------------- ---------- ---------- ---------- ---------- --------
When I do this I get this error:
Server Error in '/ArkenImages' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Unable to cast object of type 'System.Data.DataSet' to type 'System.Collections.IEnume rable'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastExceptio n: Unable to cast object of type 'System.Data.DataSet' to type 'System.Collections.IEnume rable'.
Source Error:
Line 96: Dim i As Integer
Line 97:
Line 98: For Each i In cImage.GetImagesByNodeID(e .NodeCheck ed.Value)
Line 99:
Line 100: 'ILoad1.Value = WebImage.Load(Server.MapPa th("Upload s/images") , cImage.imageID)
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Grateful to get help in how to be able to go through each row in the dataset to perform some actions.
Peter
I'm trying to go through a dataset row by row to do some changes for each row. I tried this code using a treeview checkbox click to activate the procedure:
--------------------------
Protected Sub RadTreeView2_NodeCheck(ByV
If e.NodeChecked.Value > 1 Then
Dim cImage As New imagesDL
Dim i As Integer
For Each i In cImage.GetImagesByNodeID(e
Label1.Text = cImage.imageID
Next
End If
Response.Redirect(Request.
End Sub
--------------------------
When I do this I get this error:
Server Error in '/ArkenImages' Application.
--------------------------
Unable to cast object of type 'System.Data.DataSet' to type 'System.Collections.IEnume
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastExceptio
Source Error:
Line 96: Dim i As Integer
Line 97:
Line 98: For Each i In cImage.GetImagesByNodeID(e
Line 99:
Line 100: 'ILoad1.Value = WebImage.Load(Server.MapPa
--------------------------
Grateful to get help in how to be able to go through each row in the dataset to perform some actions.
Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried this and it didn't complain:
Dim cImage As New imagesDL
Dim row As DataRow
Dim ds As DataSet = cImage.GetImagesByNodeID(e
For Each row In ds.Tables(0).Rows
'ILoad1.Value = WebImage.Load(Server.MapPa
'ILoad1.Value.Delete()
Label1.Text = cImage.imageID
'Response.Write(row.Item)
Next
--------------------------
But how would I get the id for each row?
Peter