I passed List as Model to WebGrid Constructor.
@model List<string>
@{
var grid = new WebGrid(Model);
}
<div>
@grid.GetHtml()
</div>
I am expecting to get my List of string with grid. But I got length of string. Weird?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That is weird, but the explanation is that the WebGrid looks for public properties of the row objects in order to display them as columns; it just so happens that Length is the only property that type String exposes.
Note that you can get your desired behavior by specifying the format explicitly: