Click here to Skip to main content
12,634,651 members (24,379 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: MVC4
Hi All,

I am new to ASP.Net MVC. I am using asp.grid and objectdatasource in MVC ASPX Application. I am not able retain the values of p_startindex, datakeynames etc. In many blogs it is mentioned like viewstate is not supported in MVC. Is there any alternate method to achive my task.

The below code is placed in View/Index.aspx page

<asp:GridView ID="grVw" runat="server" DataKeyNames="Id, Name" PageSize="10"
                    AllowPaging="true" AllowSorting="true" DataSourceID="ObjectDataSource" AutoGenerateColumns="False"
                    AutoGenerateCheckBoxColumn="True" CheckBoxColumnIndex="0">
                    <EmptyDataTemplate>
                        No Matching Records Found
                    </EmptyDataTemplate>
                    <Columns>
                        <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    </Columns>
                </asp:GridView>
                <asp:ObjectDataSource ID="ObjectDataSource" runat="server" MaximumRowsParameterName="p_maxRows"
                    StartRowIndexParameterName="p_startIndex" TypeName="MVCSampleApplication.Controllers.DefaultController"
                    SelectMethod="GetList" SelectCountMethod="GetListCount" SortParameterName="p_sortData"
                    EnablePaging="true">
                    <SelectParameters>
                        <asp:Parameter Name="p_sortData" Type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>


Thank you
Posted 8-Nov-12 20:10pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100