Results 1 to 5 of 5

Thread: [RESOLVED] [2005] C# to VB Conversion question

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Resolved [RESOLVED] [2005] C# to VB Conversion question

    The below line was in the markup of a C# asp.net page, what would be the equivalent in VB? The datasource item is what I need. The code behind file converted fine, but this line is giving me an error of "The DataSource property cannot be set declaratively". No matter what I try to set it to, it doesn't seem to like the fact that you are using code for that property, but it does work in C#.
    Code:
    <asp:Repeater ID="Repeater1" runat="server" DataSource="<% ((SiteMapNode) Container.DataItem).ChildNodes %>">

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    Toronto, ON
    Posts
    1,093

    Re: [2005] C# to VB Conversion question

    Try changing DataSource to DataSourceID and see if that helps.
    (VB/C#) is clearly superior to (C#/VB) because it (has/doesn't have) <insert trivial difference here>.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: [2005] C# to VB Conversion question

    But datasourceID would be the name of a defined datasource, correct? It looks like they are using the actual nodes of an object there, in an undefined datasource, so you can't reference it by an ID.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: [2005] C# to VB Conversion question

    Im thinking its a cast statement, so the equivalent line would be something like
    Code:
    <% DirectCast(Container.DataItem, SiteMapNode).ChildNodes %>
    or by using CType, but no matter what I put VB doesn't like it and won't compile with the error stated in the first post. Can you not do this in VB?

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: [2005] C# to VB Conversion question

    Hehe... I forgot the '#' symbol after the opening tag... that was the problem...
    Code:
    DataSource="<%# DirectCast(Container.DataItem, SiteMapNode).ChildNodes %>"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width