webgrid

ASP.NET MVC 3 WebGrid paging issue

戏子无情 提交于 2019-12-03 17:11:43
问题 My data access layer returns collection with rows for single page and total number of rows. Unfortunately WebGrid component does not allow to specify total number of rows or total number of pages (these properties are read-only). Has anyone had to deal with this issue before? 回答1: You can use the Bind method on the WebGrid to tell the grid to use server side paging. grdv.Bind(myData, rowCount=10000, autoSortAndPage=False) Setting autoSortAndPage to false tells the grid that myData is just a

Asp.net Mvc3 webgrid and paging

佐手、 提交于 2019-12-03 12:12:17
I am trying to learn Asp.net mvc. I know its different from forms and i need to change my way of thinking probably. My problem is about webgrid . When i add webgrid to my page and hit search button with Post it renders table with pager and so on. But links on the pager is not posting form they are just links and i lost all my form's data. Controller has two index methods one is for get and other is for post. For get i do nothing, I just create new viewmodel in this case Search class and set it to view. For my post method i grab my view model do search and set filled viewmodel to view. problem

How can I use DisplayName data annotations for column headers in WebGrid?

为君一笑 提交于 2019-12-03 11:53:34
问题 I have a Car class that I'm trying to display in an MVC 3 view using the WebGrid helper. Below are the Car and it's metadata class. Car class: [MetadataType(typeof(CarMetadata))] public partial class Car { // car implementation } Car metadata class: public class CarMetadata { [DisplayName("Car Name")] [StringLength(100, ErrorMessageResourceType = typeof(ValidationText), ErrorMessageResourceName="CarNameDescriptionLength")] [Required] public string CarName { get; set; } } View contents: @model

How to format date in mvc web grid

旧街凉风 提交于 2019-12-03 11:22:06
问题 I have a web grid and I am not using razor syntex.Rather I am using the .aspx form. the code is below; <% var grid = new WebGrid(Model,defaultSort:"PublishDate",rowsPerPage:10); %> <%: grid.GetHtml( tableStyle: "wGrid", headerStyle: "wGridHeader", alternatingRowStyle: "alt", columns: grid.Columns( grid.Column("Title", canSort: false), grid.Column("PublishDate", "Published on"), grid.Column("CategoryName", "Category"), grid.Column(format: (item) => Html.ActionLink("Details", "Browse", new { id

asp.net mvc 3 webgrid sorting remains ?sortdir=ASC

故事扮演 提交于 2019-12-03 10:03:51
问题 I'm experimenting a bit with several grids in asp.net mvc. Microsoft has a grid too know in the prerelease of mvc 3 so I thought I'll try that one out. The basic functionality is quite easy to implement but when it comes to sorting, I'm having some problems. The grid handles its sorting by the url. In the url you have the sort column and the sort direction in the following way: ?sortdir=ASC&sort=ABONNEMENT Now you would expect that after you've done the sorting on the certain column, the

ASP.NET MVC 3 WebGrid paging issue

自古美人都是妖i 提交于 2019-12-03 05:28:36
My data access layer returns collection with rows for single page and total number of rows. Unfortunately WebGrid component does not allow to specify total number of rows or total number of pages (these properties are read-only). Has anyone had to deal with this issue before? You can use the Bind method on the WebGrid to tell the grid to use server side paging. grdv.Bind(myData, rowCount=10000, autoSortAndPage=False) Setting autoSortAndPage to false tells the grid that myData is just a segment of the data. It will show all rows of this data regardless of your page size setting. Pager will be

How to format date in mvc web grid

孤者浪人 提交于 2019-12-03 02:55:09
I have a web grid and I am not using razor syntex.Rather I am using the .aspx form. the code is below; <% var grid = new WebGrid(Model,defaultSort:"PublishDate",rowsPerPage:10); %> <%: grid.GetHtml( tableStyle: "wGrid", headerStyle: "wGridHeader", alternatingRowStyle: "alt", columns: grid.Columns( grid.Column("Title", canSort: false), grid.Column("PublishDate", "Published on"), grid.Column("CategoryName", "Category"), grid.Column(format: (item) => Html.ActionLink("Details", "Browse", new { id = item.Title })) ) ) %> Now I want to format the 'PublishDate' column to something like 'dd-MMM-yyyy'.

How can I use DisplayName data annotations for column headers in WebGrid?

妖精的绣舞 提交于 2019-12-03 02:12:52
I have a Car class that I'm trying to display in an MVC 3 view using the WebGrid helper. Below are the Car and it's metadata class. Car class: [MetadataType(typeof(CarMetadata))] public partial class Car { // car implementation } Car metadata class: public class CarMetadata { [DisplayName("Car Name")] [StringLength(100, ErrorMessageResourceType = typeof(ValidationText), ErrorMessageResourceName="CarNameDescriptionLength")] [Required] public string CarName { get; set; } } View contents: @model List<Car> ... var grid = new WebGrid(Model, canPage: true, rowsPerPage: 10); grid.Pager

asp.net mvc 3 webgrid sorting remains ?sortdir=ASC

跟風遠走 提交于 2019-12-02 23:18:24
I'm experimenting a bit with several grids in asp.net mvc. Microsoft has a grid too know in the prerelease of mvc 3 so I thought I'll try that one out. The basic functionality is quite easy to implement but when it comes to sorting, I'm having some problems. The grid handles its sorting by the url. In the url you have the sort column and the sort direction in the following way: ?sortdir=ASC&sort=ABONNEMENT Now you would expect that after you've done the sorting on the certain column, the sortdir querystring on that column would change to ?sortdir=DESC but it doesn't. It stays ?sortdir=ASC .

Add custom attributes to table rendered by WebGrid

时光怂恿深爱的人放手 提交于 2019-12-02 11:56:29
问题 I am using an MVC3 WebGrid, and want to add custom attributes of the form "data-xxx" to the <table> element rendered by WebGrid.GetHtml() . I tried to do this as follows: grid.GetHtml(... htmlAttributes: new { data_xxx = "value" } ); However this renders as: <table ... data_xxx="value"> instead of the expected: <table ... data-xxx="value"> I.e. unlike other MVC helpers, it doesn't replace the underscore in the property name with a hyphen. After a bit of spelunking with Reflector it seems that