Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
986 views
in Technique[技术] by (71.8m points)

asp.net mvc - How to insert drop down list box in a Telerik grid

I have a Telerik Grid, with two columns I need to keep second column as drop-down list box with in the grid, I am using ASP.NET MVC control

Can any body tell me how to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I need to do that for my project. Here is how I did it:

columns.Bound(o => o.Role).ClientTemplate(
                Html.Telerik().DropDownList()
                    .Name("RoleList<#= UserID #>")
                    .BindTo(new SelectList(UserController.GetRoles()))
                    .ToHtmlString()
            );

The static method GetRoles returns a simple IEnumerable of String. You still can return a custom object by using a different SelectList constructor to specify Value and Text property of your custom object.

new SelectList(UserController.GetCustomRoles(), "RoleID", "ShortName")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...