TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhishek Shrivastava
1.6k
152
7k
How display two columns in Mvc WebGrid with single object
May 25 2017 8:36 AM
I am new to MVC and I want to display name of a user in two columns in a WebGrid as display below.
User 1
User 2
User 3
User 4
Currently the web grid display data in below format.
User 1
User 2
User 3
User 4
I am binding my WebGrid with List<string>, list contains username.
My Controller
public ActionResult Index()
{
List<string> userList = new List<string>();
userList.Add("User1");
userList.Add("User2");
userList.Add("User3");
userList.Add("User4");
return View(userList);
}
My Cshtml
enter code here
@using (Html.BeginForm())
{
var grid = new WebGrid(Model);
@grid.GetHtml(columns: grid.Columns(grid.Column(format: (item) => item)));
}
Reply
Answers (
2
)
Reading A python file without installing Iron Python
MVC Sessions extending timeout time w/o losing sessions vars