Search code examples
asp.net-mvcdynamicwebgrid

Losing web controls data when navigating from one page to other in webgrid which is in aspx page


Hi I had a webgrid in my aspx page with paging, when I try to navigate from one page to other page in the webgrid. I am losing data of other controls in aspx page. Basically the webgrid when navigating from one page to other its trying to reload the whole aspx page.

My question is how to make this webgrid stand alone in my aspx page and not to reload the page when mvoing from one page to other

Thank you in advance

    <html>
<head>
    <title>Index</title>
    <style type="text/css">
        .webGrid { margin: 4px; border-collapse: collapse; width: 300px; }
        .header { background-color: #E8E8E8; font-weight: bold; color: #FFF; }
        .webGrid th, .webGrid td { border: 1px solid #C0C0C0; padding: 5px; }
        .alt { background-color: #E8E8E8; color: #000; }
        .person { width: 200px; font-weight:bold;}
    </style>
</head>
<body>            
    @{
        var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5);
        grid.Pager(WebGridPagerModes.NextPrevious);
        @grid.GetHtml(tableStyle: "webGrid",
                htmlAttributes: new { id = "DataTable" },
                headerStyle: "header",
                alternatingRowStyle: "alt",
                columns: grid.Columns(
                    grid.Column("Age"),
                    grid.Column("Id"),
                    grid.Column("Name")
        ));       
    }
    <input type="text" id="somed" /><select><option value="some">test1</option><option value="some2">test2</option><option value="some3">test3</option></select>
</body>
</html>

In here I have a text box and a dropdown, so whenever i try to navigate from one page to other the value in text box and the selected dropdown values are gone.


Solution

  • after hours of searching I found a link which can help..

    here is the link http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx