We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Getting started with VB.Net?

Any examples of basic getting started code in VB.Net? I can translate C# code for the controllers to VB.Net via one of the many translators out there. The view code is another thing all together.

Thanks


3 Replies

GC Greg Clouston October 5, 2010 01:13 PM UTC

Here's the code I'm trying to translate:

%=Html.Grid("FlatGrid")
.Datasource(Model)
.EnablePaging()
.EnableSorting()
.Column( column => {
column.Add(c => c.OrderID).HeaderText("Order ID");
column.Add(c => c.CustomerID).HeaderText("Customer ID");
column.Add(c => c.EmployeeID).HeaderText("Employee ID");
column.Add(c => c.OrderDate).HeaderText("Order Date").Format("{OrderDate:dd/mm/yyyy}");
column.Add(c => c.Freight).HeaderText("Freight");
})
%>




GC Greg Clouston October 5, 2010 05:58 PM UTC

I've managed to make some head way. I ended up translating the code into this:


<%= Html.Grid(Of MvcSampleApplication.Order)("FlatGrid") _
.Datasource(Model) _
.EnablePaging() _
.EnableSorting() _
.Column(Function(columns) {
columns.Add(Function(c) c.OrderID).HeaderText("Order ID"),
columns.Add(Function(c) c.CustomerID).HeaderText("Customer ID"),
columns.Add(Function(c) c.EmployeeID).HeaderText("Employee ID"),
columns.Add(Function(c) c.OrderDate).HeaderText("Order Date").Format("{OrderDate:dd/mm/yyyy}"),
columns.Add(Function(c) c.Freight).HeaderText("Freight")})
%>

Now I've got something grid-like being displayed but it is far from what the example looks like. See attached image. Is this a control registration issue?






SyncFusion support 01_8c0144cc.rar


KD Krishnaraj D Syncfusion Team October 8, 2010 05:28 AM UTC


Hi Greg Clouston,

Thanks for your interest in Syncfusion Products.

Please refer the below view code snippets for Grid in VB.


<% 'Define the grid and enable the require features like paging and sorting
Dim gridbuilder = Html.Grid(Of MvcApplication3.employee)("Grid1").Datasource(Model).EnablePaging().EnableSorting()

'add grid columns using gridbuilder
gridbuilder.Column(Function(cols) cols.Add(Of Integer)(Function(c As MvcApplication3.employee) c.emp_id).HeaderText("Employee ID"))
gridbuilder.Column(Function(cols) cols.Add(Of String)(Function(c As MvcApplication3.employee) c.fname).HeaderText("Employee Name"))
gridbuilder.Column(Function(cols) cols.Add(Of Integer)(Function(c As MvcApplication3.employee) c.job_id).HeaderText("Job Id"))
gridbuilder.Column(Function(cols) cols.Add(Of Date)(Function(c As MvcApplication3.employee) c.hire_date).HeaderText("Hire Date"))

'Render the grid by using Render()
gridbuilder.Render()
%>

Refer the below code snippets for controller.

Function Index() As ActionResult
Dim northwind As PUBSEntities3 = New PUBSEntities3

Return View(northwind.employees)
Return View()
End Function

_
Function Index(ByVal args As PagingParams) As ActionResult

Dim northwind As PUBSEntities3 = New PUBSEntities3

Dim data As IEnumerable = Nothing
data = northwind.employees
Return data.GridActions(Of employee)()
End Function

Please let us know if you have any queries.

Regards,
Krishnaraj D





Loader.
Live Chat Icon For mobile
Up arrow icon