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

[VB.NET/GridView] Problems adding command buttons and binding the action

3 Answers 140 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.
Michiel Peeters
Top achievements
Rank 1
Michiel Peeters asked on 22 Apr 2010, 03:30 PM
Dear Telerik Community,

Currently I'm creating a MVC application in VB.NET (3.5) which is kinda suckage i know but i need to do this for my trainee job. I'm quite happy and far with implementing the gridview only i have some trouble with the command buttons. Let me explain to you:

 

Dim gridBuilder = Html.Telerik().Grid(Model)

 

gridBuilder.Name(

"Grid")

 

gridBuilder.DataKeys(

Function(keys) keys.Add(Function(value) value.Id))

 

gridBuilder.DataBinding(

Function(binding) binding.Server().Update("UpdateEmployee", "User").Select("DetailsEmployee", "User"))

This is the first section of the grid. The wierdest thing what happened is when i only apply the update to the bind inline editing is available. So i though hey lets add select which will redirect me to the details page. It worked only the update command button redirects also to the detailsemployee page (there is my problem)?

Ok, because the lack of lambda expressions (multiline) in VB.NET (3.5) i had to add the command buttons like this:

 

gridBuilder.Columns(

Function(columns) columns.Command(Function(o) o.Select()).Width(0))

 

gridBuilder.Columns(

Function(columns) columns.Command(Function(o) o.Edit()).Width(0))

 


Well, both show up and are clickable but both redirects to the detailsemployee page. I think that the problem is VB.NET instead of Telerik. I hope you guys can show me in the right direction.

Kind regards,
Michiel Peeters

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 22 Apr 2010, 03:46 PM
Hi Michiel Peeters,

Indeed VB.NET does not support multiline lambdas which makes working with the mvc grid a bit difficult. Here is a demo showing how to use commands column in VB:

<%  Dim grid = Html.Telerik().Grid(Of VisualBasicMvcGrid.Model)(Model) _
        .Name("Grid") _
        .Pageable() _
        .Sortable() _
        .Columns(Function(columns) columns.Bound(Function(model) model.Data).Title("Column1")) _
        .Columns(Function(columns) columns.Bound(Function(model) model.Data).Title("Column2"))
   
    Dim commandColumn As New GridActionColumn(Of VisualBasicMvcGrid.Model)(grid.ToComponent())
    commandColumn.Commands.Add(New GridEditActionCommand(Of VisualBasicMvcGrid.Model))
    commandColumn.Commands.Add(New GridDeleteActionCommand(Of VisualBasicMvcGrid.Model))
    grid.ToComponent().Columns.Add(commandColumn)
    grid.Render()
 %>

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Michiel Peeters
Top achievements
Rank 1
answered on 22 Apr 2010, 07:46 PM
Dear Atanas,

Thank you for the code snippit and yes it works, only my column is now very wide but that shouldnt be any problem te fix. Now i have a another problem. Could you provide me in a code snippit how i can handle column.Template? If you can do that i will provide the complete grid layout in VB.NET. You can use it then for VB.NET support and people that program in VB.NET can use it :).

Kind regards,
Michiel Peeters
0
Georgi Krustev
Telerik team
answered on 23 Apr 2010, 10:09 AM
Hello Michiel,

You can use the following code snippet:
column.Template = (Function(p As Product) "<ul>" + _
                  "<li>" + p.ProductID + "</li>" + _
                  "<li>" + p.ProductName + "</li>" + _
              "</ul>")

Greetings,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Michiel Peeters
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Michiel Peeters
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or