Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: for each item in collection loop does not work for datatable

0
0
I tried this in JScript and it does not work (same as VBScript):
js.Execute("for(row in dt.Rows) { for(col in row.Table.Columns) { Response.Write row(col.ColumnName).ToString(); } }")
Can this work in V8 ? I don't mind using Count and Item properties for iteration but I would prefer this more.

If I declare row and col (the variables I use in the engine) initially as then I get error invalid assignment:
Public row as DataRow
Public col as DataColumn 

Public Sub Initialize()

js.AddRestrictedHostObject("me", HostItemFlags.GlobalMembers, Me)
js.Execute("for(row in dt.Rows) { for(col in row.Table.Columns) { Response.Write row(col.ColumnName).ToString(); } }")

End Sub
If I dont declare the variables it gives error as: Object not a collection at Microsoft.ClearScript.ScriptEngine

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images