ASP.NET MVC 4 and C#
- I need to know how to avoid a refresh webgrid
page when click next page without losing values of textbox
(txtMessage). My problem is that when I input values in some Message textbox
in a first page and then click the next page and go back to the first page, the values are gone. How to keep values no matter how times you click next page or go back. I have been trying to find solution on Google but I am lost how to solve it.
@{
Layout = "~/Views/Shared/_Layout.cshtml";
var grid = new WebGrid(Model, rowsPerPage: 100, ajaxUpdateContainerId: "gridcontent");
}
<div id="gridcontent" >
@grid.GetWebGrid(
htmlAttributes: new { id = "grid" },
tableStyle: "grid",
headerStyle: "grid-header",
footerStyle: "grid-footer",
selectedRowStyle: "rid-selected-row",
alternatingRowStyle:"grid-alternating-row",
rowStyle: "grid-row-style",
mode: WebGridPagerModes.FirstLast | WebGridPagerModes.Numeric | WebGridPagerModes.NextPrevious,
numericLinksCount: 5,
firstText: "<< First",
previousText: "< Previous",
lastText: "Last >>",
nextText: "Next >",
columns: grid.Columns(
grid.Column(columnName: "AnimalId", header: "Animal ID", style: "colId", format: (item) => string.IsNullOrEmpty(item.AnimalId) ? string.Empty : item.AnimalId),
grid.Column(columnName: "MessageValue", header: "Message", format: (item) => Html.TextBox("txtMessage", (object)item.MessageValue), canSort: false,),
grid.Column(header: "View Details", format: @<text><input id="btnView " type="button" value="Details" /></text>),
))
</div>