Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

XML
<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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900