@{
var custm = (List<custDis>)TempData["custom"];
var count=1;
var grid = new WebGrid(custm, canPage: true, canSort: true, rowsPerPage: 5,ajaxUpdateContainerId:"grid");
}
@grid.GetHtml(
tableStyle:"webgrid",
headerStyle:"webgrid-header",
footerStyle: "webgrid-footer",
alternatingRowStyle: "webgrid-alternating-row",
rowStyle:"webgrid-row-style",
columns:
grid.Columns(
grid.Column("S.N.", format:@<text>@count </text> ),
grid.Column("Name",format:@<text>@item.name</text>)
))
I have web grid as above. the webgrid displays name. I want to add s.n. in the web grid how can I do that. I tried to use counter but i don't know where should I increase its value. how can I add the s.n. in above code.
If I understand you, you want to add counter for your webgrid on the view, that can look like this :
grid.Column("S.N.", format:p=>count++)
But if you want to add paging for webgrid this won't work, because every time the counter will set to 1.