views:

14

answers:

1

Im using a Custom NestedRepeater Control for ASP.NET which can be found on code project

The source is in c# which i have converted to vb and plugged into my solution, so far so good. The problem, im having is databinding to the repeater, my code behind looks like this...

    '' get all pages
    Dim navPages As DataSet = Navigation.getMenuStructure()
    navPages.Relations.Add(navPages.Tables(0).Columns("ID"), navPages.Tables(0).Columns("ParentID"))
    NestedRepeaterNavigation.RelationName = RelationName
    NestedRepeaterNavigation.DataSource = navPages
    NestedRepeaterNavigation.RowFilterTop = "ParentID is null"
    NestedRepeaterNavigation.DataBind()

Then in the item template of my custom repeater im trying the following...

<ItemTemplate>
    <img src="/pix.gif" height="10" width="<%#(Container.Depth * 10)%>">
<%# (Container.DataItem as DataRow)["DESCRIPTION"]%>
<%# (Container.NbChildren != 0 ? "<small><i>(" + Container.NbChildren.ToString() +")</i></small>" "") %><small><i></i></small>
</ItemTemplate>

The databinding falls over; firstly that 'as DataRow' says it was expecting an ')'. And secondly that '!=' identifier expected.

Is this due to the translation from c#, should the databinding be different?

A: 

Though I've not programmed in VB.net for long (about 3 years) but I know that AS is not applicable in VB.net you need ctype to cast Container.DataItem like

CType(Container.DataItem, DataRow).

you can also try DirectCast(Container.DataItem, DataRow) but I don't think this will work.

Also for inequality comparison you can use

Not Container.DataItem = 0

but not !=

TheVillageIdiot
Thanks for your reply! Could you show me how i would cast this?
Dooie