This is a migrated thread and some comments may be shown as answers.

VB.NET

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick Barranis
Top achievements
Rank 1
Patrick Barranis asked on 04 Feb 2010, 08:22 PM
Hi.  I'm working on a project in VB.NET that's being converted from WebForms to MVC.  Unfortunately I'm stuck in VB though I'd rather use C#.  This is 2008/.NET3.5 (VB 9), not VB10.

I see the posts about how there are limitations to doing this in VB, but I'm wondering if it's possible at all.  Can someone please help me convert a simple piece of code like the following into VB?  I've tried converter.telerik.com, but the piece of code that results still won't compile.

    Html.Telerik().Grid(Model)  
        .Name("OrdersGrid")  
        .Columns(colums =>  
        {  
            colums.Add(o => o.OrderID);  
            colums.Add(o => o.ShipAddress);  
            colums.Add(o => o.RequiredDate);  
        })  
        .Pageable()  
        .Sortable()  
        .Render();  
 

Thanks!

2 Answers, 1 is accepted

Sort by
0
Patrick Barranis
Top achievements
Rank 1
answered on 04 Feb 2010, 09:02 PM
I seem to have stumbled over the answer to my own question.  Since VB.NET doesn't support multi-line lambda expressions the same way as C# (though it clearly states in documentation that they're supported, so I'm still confused about this), you jsut have to add the columns one at a time, so to speak.  Here's my actual code:
        Html.Telerik.Grid(Of DisplayRow)(Model).Name("InspectionsGrid") _  
            .Columns(Function(c) c.Add(Function(m) m.SiteName).Title("Site Name").Template( _  
                         Function(m) String.Format("<a href='/inspection/?SiteActivityGUID={0}' title='{0}'>{1}</a>", m.SiteActivityGUID, m.SiteName))) _  
            .Columns(Function(c) c.Add(Function(m) m.ActivityDate).Title("Date").Format("{0:d}")) _  
            .Columns(Function(c) c.Add(Function(m) m.Latitude).Title("Latitude")) _  
            .Columns(Function(c) c.Add(Function(m) m.Longitude).Title("Longitude")) _  
            .Columns(Function(c) c.Add(Function(m) m.City).Title("City")) _  
            .Columns(Function(c) c.Add(Function(m) m.State).Title("State")) _  
            .Columns(Function(c) c.Add(Function(m) m.TowerType).Title("Tower Type")) _  
            .Columns(Function(c) c.Add(Function(m) m.Ownership).Title("Ownership")) _  
            .Render()  
 

0
Patrick Barranis
Top achievements
Rank 1
answered on 04 Feb 2010, 09:04 PM
Off topic: why don't the Telerik forums allow you to mark your own post as an answer?  It seems like one out of every ten posts on the MSDN forums are self-answered, so it seems like a much-needed feature...

Just my two cents :)
Tags
Grid
Asked by
Patrick Barranis
Top achievements
Rank 1
Answers by
Patrick Barranis
Top achievements
Rank 1
Share this question
or