I want to put some hidden columns in the Webgrid. there a few key columns in my output which are not to be shown to the users but I need them to be present in the webgrid. I require these columns in the grid because when a user selects the row in the grid
and clicks on modify I need those keys to get the details of selected columns.Can you please tell me how can I have a hidden column in the webgrid?(razor vb.net syntax please)
why would you do that? just put the key values in the edit link.
Agree. WebGrid is different from GridView. WebGrid issue a GET request when you click a link. So it will not include any hidden form value. On, the other hand GridView is based on POST (when you use linkbutton).
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
ParikshitMVC
0 Points
2 Posts
Putting a hidden column in WebGrid MVC3
Dec 16, 2011 02:39 PM|LINK
I want to put some hidden columns in the Webgrid. there a few key columns in my output which are not to be shown to the users but I need them to be present in the webgrid. I require these columns in the grid because when a user selects the row in the grid and clicks on modify I need those keys to get the details of selected columns.Can you please tell me how can I have a hidden column in the webgrid?(razor vb.net syntax please)
bruce (sqlwo...
All-Star
36836 Points
5443 Posts
Re: Putting a hidden column in WebGrid MVC3
Dec 16, 2011 02:55 PM|LINK
why would you do that? just put the key values in the edit link.
Bianca Hulub...
Member
202 Points
37 Posts
Re: Putting a hidden column in WebGrid MVC3
Dec 16, 2011 11:24 PM|LINK
Hi,
You can set a hidden column by adding to format input type hidden:
.cshtml
@{
var grid = new WebGrid(Model);
@grid.GetHtml(columns: grid.Columns(grid.Column(null,null, format: @<input type="hidden" name="IDHidden" value="@item.IDHidden"/>),
grid.Column("Title", "Title")));
}
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Putting a hidden column in WebGrid MVC3
Dec 17, 2011 05:57 AM|LINK
Agree. WebGrid is different from GridView. WebGrid issue a GET request when you click a link. So it will not include any hidden form value. On, the other hand GridView is based on POST (when you use linkbutton).
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD