Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

this code getting from internet..
i can't understand the below code..
i am very confusing about this code..

any one please help me for understand this code..

HTML
@*@(Html.Kendo().DropDownList()
                                                   .BindTo((IEnumerable<StackedSports.Models.SportsTeamViewModel>)ViewBag.SportsName)
                                   .OptionLabel("- Select Sports Group - ")
                                           .DataValueField("SportsTeamGroupID")
                                           .DataTextField("GroupName")
                                   .Name("unvdeptspt")
                                   )


Regards
-AR
Posted

Normally the code that begin with an "@*" is a comment, but supposing that was a mistake when you write your code, here is the explanation:
1.Code that begin with @Html. normally is a HTML helper (standard or custom made) that render a new control or even partial view to the current page.
2. Kendo().DropDownList() -tell me nothing and if is a part of custom made HTML helper should have some parameters and not an invocation of a method like DropDownList();
3. BindTo part get some data from ViewBag named SportsName, convert them back to an enumerable of type SportsTeamViewModel (data that were cached from the controller), then bind them to the drop down list named "unvdeptspt".

But the entire code seems to be incorrect as I know from MVC3 and MVC4.
 
Share this answer
 
v2
SQL
The above code binds data from viewbag.sportsname to the third party controls provided by telerik for mvc I.e kendo control wherein the datavaluefield basically holds the id and datatextfield specifies the text that will be displayed by the kendo dropdown.

1)optionlabel specifies the default value that the kendo dropdown will display.
2)name specifies the name that you assign to the kendo dropdownlist this is similar to what we do with normal html controls
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900