Click here to Skip to main content
15,123,367 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

Instead of getting all the records, I am getting the 20 records on each and every Request i.e, First, Next, Previous and Last for the ASPxGridView. Here All are working expect Previous.

For getting Previous records

C#
if (Session["PageSize"] != null)
                   int.TryParse(Session["PageSize"].ToString(), out pageSize);

               test = CreateTestData();
               testDatas = test.Reverse().Skip(-pageSize).Take(20).ToArray();
               test.Count();
               Session["test"] = testDatas;

               tempPageSize = pageSize - 20;

               Session["PageSize"] = tempPageSize;


It's not working for me.

For this I tried the below code.

What I have tried:

JavaScript
function OnEndCallBack(s, e) {
    GvBOLList.Refresh();
}

function OnFirst() {
    callBack.PerformCallback("OnFirst");
}

function OnPrvs() {
    callBack.PerformCallback("OnPrvs");
}

function OnNext() {
    callBack.PerformCallback("OnNext");
}

function OnLast() {
    callBack.PerformCallback("OnLast");
}


ASP.NET
<dx:ASPxCallback ID="callBack" runat="server" ClientInstanceName="callBack" OnCallback="callBack_Callback">
            <ClientSideEvents EndCallback="OnEndCallBack" />
        </dx:ASPxCallback>
        <dx:ASPxHiddenField ID="hdnPaging" runat="server" ClientInstanceName="hdnPaging" OnCustomCallback="hdnPaging_CustomCallback"></dx:ASPxHiddenField>
        <dx:ASPxGridView ID="GvBOLList" ClientInstanceName="GvBOLList" runat="server" AutoGenerateColumns="false" KeyFieldName="Name" Width="100%"
            CssClass="grid" OnDataBinding="GvBOLList_DataBinding">
            <Columns>
                <dx:GridViewDataColumn VisibleIndex="0" Caption="Name" FieldName="Name" HeaderStyle-Font-Bold="true">
                </dx:GridViewDataColumn>
                <dx:GridViewDataTextColumn FieldName="Role" Caption="Role" HeaderStyle-Font-Bold="true" VisibleIndex="1">
                </dx:GridViewDataTextColumn>
            </Columns>
            <SettingsBehavior EnableCustomizationWindow="true" AllowFocusedRow="true" />
            <Settings VerticalScrollBarMode="Visible" />
            <SettingsBehavior AllowEllipsisInText="true" />
            <SettingsPager Mode="EndlessPaging" PageSize="10" />
            <SettingsLoadingPanel Mode="Disabled" />
            <Settings ShowFooter="true" ShowHeaderFilterButton="true" />
            <SettingsBehavior AllowFocusedRow="true" AllowSelectByRowClick="true" AllowSelectSingleRowOnly="true" ProcessSelectionChangedOnServer="false" ProcessFocusedRowChangedOnServer="false" />
        </dx:ASPxGridView>
        <div style="width: 100%; border-width: 1px; border-style: solid; border-color: #BED6F6; width: 100%; text-align: center;">
            <table class="OptionsTable" style="width: 10%">
                <tr>
                    <td style="padding-left: 8px;">
                        <dx:ASPxImage ID="ASPxImage9" runat="server" ClientInstanceName="Btnfirst" CssClass="pagingstyle">
                            <EmptyImage IconID="arrows_doublefirst_32x32"></EmptyImage>
                            <ClientSideEvents Click="OnFirst" />
                        </dx:ASPxImage>
                    </td>
                    <td>
                        <dx:ASPxImage ID="ASPxImage10" runat="server" ClientInstanceName="BtnPrvs" CssClass="pagingstyle">
                            <EmptyImage IconID="arrows_doubleprev_32x32"></EmptyImage>
                            <ClientSideEvents Click="OnPrvs" />
                        </dx:ASPxImage>
                    </td>
                    <td>
                        <dx:ASPxImage ID="ASPxImage11" runat="server" ClientInstanceName="BtnNext" CssClass="pagingstyle">
                            <EmptyImage IconID="arrows_doublenext_32x32"></EmptyImage>
                            <ClientSideEvents Click="OnNext" />
                        </dx:ASPxImage>
                    </td>
                    <td>
                        <dx:ASPxImage ID="ASPxImage12" runat="server" ClientInstanceName="BtnLast" CssClass="pagingstyle">
                            <EmptyImage IconID="arrows_doublelast_32x32"></EmptyImage>
                            <ClientSideEvents Click="OnLast" />
                        </dx:ASPxImage>
                    </td>
                </tr>
            </table>
        </div>


C#
TestData[] testDatas;
    TestData[] test;

    int pageSize;
    int tempPageSize;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["test"] = null;
            GvBOLList.DataBind();
        }
    }

 protected void GvBOLList_DataBinding(object sender, EventArgs e)
    {
        (sender as ASPxGridView).DataSource = GetData();
    }

 protected void callBack_Callback(object source, DevExpress.Web.CallbackEventArgs e)
    {

        switch (e.Parameter)
        {
            case "OnFirst":
                Session["PageSize"] = 20;
                test = CreateTestData();
                testDatas = test.Take(20).ToArray();
                Session["test"] = testDatas;
                break;
            case "OnPrvs":

                if (Session["PageSize"] != null)
                    int.TryParse(Session["PageSize"].ToString(), out pageSize);

                test = CreateTestData();
                testDatas = test.Reverse().Skip(-pageSize).Take(20).ToArray();
                test.Count();
                Session["test"] = testDatas;

                tempPageSize = pageSize - 20;

                Session["PageSize"] = tempPageSize;

                break;
            case "OnNext":

                if (Session["PageSize"] != null)
                    int.TryParse(Session["PageSize"].ToString(), out pageSize);

                test = CreateTestData();
                testDatas = test.Skip(pageSize).Take(20).ToArray();
                Session["test"] = testDatas;

                tempPageSize = pageSize + 20;

                Session["PageSize"] = tempPageSize;

                break;
            case "OnLast":


                test = CreateTestData();
                testDatas = test.Reverse().Take(20).Reverse().ToArray();
                Session["test"] = testDatas;


                break;
        }
    }

 public class TestData
    {
        public string Name { get; set; }
        public string Role { get; set; }
    }

    /// <summary>  
    /// In memory Data source  
    /// </summary>  
    /// <returns></returns>  
    public TestData[] CreateTestData()
    {
        List<TestData> data = new List<TestData>();
        data.Add(new TestData { Name = "Jignesh", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish", Role = "Developer" });
        data.Add(new TestData { Name = "Parth", Role = "Developer" });
        data.Add(new TestData { Name = "Manish", Role = "QA" });
        data.Add(new TestData { Name = "Manisha", Role = "QA" });
        data.Add(new TestData { Name = "Urmi", Role = "QA" });
        data.Add(new TestData { Name = "Bharat", Role = "QA" });
        data.Add(new TestData { Name = "Varun", Role = "QA" });
        data.Add(new TestData { Name = "Komal", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval", Role = "QA" });
        data.Add(new TestData { Name = "Chirag", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid", Role = "QA" });
        data.Add(new TestData { Name = "Vivek", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi", Role = "Architect" });
        data.Add(new TestData { Name = "Denish", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 2", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 2", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 2", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 2", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 2", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 2", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 2", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 2", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 2", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 2", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 2", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 2", Role = "QA" });
        data.Add(new TestData { Name = "Varun 2", Role = "QA" });
        data.Add(new TestData { Name = "Komal 2", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 2", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 2", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 2", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 2", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 2", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 2", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 3", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 3", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 3", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 3", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 3", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 3", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 3", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 3", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 3", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 3", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 3", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 3", Role = "QA" });
        data.Add(new TestData { Name = "Varun 3", Role = "QA" });
        data.Add(new TestData { Name = "Komal 3", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 3", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 3", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 3", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 3", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 3", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 3", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 4", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 4", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 4", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 4", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 4", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 4", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 4", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 4", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 4", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 4", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 4", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 4", Role = "QA" });
        data.Add(new TestData { Name = "Varun 4", Role = "QA" });
        data.Add(new TestData { Name = "Komal 4", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 4", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 4", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 4", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 4", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 4", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 4", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 5", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 5", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 5", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 5", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 5", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 5", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 5", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 5", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 5", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 5", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 5", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 5", Role = "QA" });
        data.Add(new TestData { Name = "Varun 5", Role = "QA" });
        data.Add(new TestData { Name = "Komal 5", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 5", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 5", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 5", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 5", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 5", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 5", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 6", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 6", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 6", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 6", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 6", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 6", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 6", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 6", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 6", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 6", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 6", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 6", Role = "QA" });
        data.Add(new TestData { Name = "Varun 6", Role = "QA" });
        data.Add(new TestData { Name = "Komal 6", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 6", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 6", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 6", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 6", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 6", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 6", Role = "Developer" });

        return data.ToArray();
    }

   private TestData[] GetData()
    {
        if (Session["test"] == null)
        {
            var test = CreateTestData();
            testDatas = test.Take(20).ToArray();
            Session["test"] = testDatas; 
            Session["PageSize"] = 20;
        }
        else
            testDatas = (TestData[])Session["test"];
        return testDatas;
    }


Can you please suggest me how to get the previous records using lambda expressions??
Posted
Updated 7-Apr-21 1:03am
Comments
Gerry Schmitz 6-Apr-21 2:08am
   
On "previous", you don't reverse; you don't negate pageSize; you subtract 20 from (session) pageSize; then skip, take, etc.
Bojjaiah 6-Apr-21 2:14am
   
let me try!

1 solution

Solved My self as below code with help of @Gerry.

C#
TestData[] testDatas;
    TestData[] test;

    int pageSize;
    int tempPageSize;
    bool isPrev = false;
    bool isLast = false;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["test"] = null;
            Session["PageSize"] = null;
            Session["endRecords"] = null;
            GvBOLList.DataBind();
        }
    }

 protected void GvBOLList_DataBinding(object sender, EventArgs e)
    {
        (sender as ASPxGridView).DataSource = GetData();
    }

 protected void callBack_Callback(object source, DevExpress.Web.CallbackEventArgs e)
    {

        switch (e.Parameter)
        {
            case "OnFirst":
                Session["PageSize"] = 0;
                test = CreateTestData();
                testDatas = test.Take(20).ToArray();
                Session["test"] = testDatas;                
                Session["endRecords"] = null;
                break;
            case "OnPrvs":

               if (Session["PageSize"] != null)
                    int.TryParse(Session["PageSize"].ToString(), out pageSize);

                tempPageSize = pageSize - 20;

                test = CreateTestData();

                if (Session["endRecords"] != null)
                {
                    Session["endRecords"] = null;
                    tempPageSize = test.Count() - 40;
                }

                testDatas = test.Skip(tempPageSize).Take(20).ToArray();
                Session["test"] = testDatas;
                isPrev = false;

                if (tempPageSize == 0)
                {
                    Session["PageSize"] = 0;
                    tempPageSize = 20;
                    isPrev = true;
                }
                else
                    Session["PageSize"] = tempPageSize;

                break;
            case "OnNext":

                if (Session["PageSize"] != null)
                {
                    int.TryParse(Session["PageSize"].ToString(), out pageSize);
                    tempPageSize = pageSize + 20;
                }
                else
                {
                    Session["PageSize"] = 20;
                    tempPageSize = 20;
                    pageSize = 20;
                }

                test = CreateTestData();
                testDatas = test.Skip(tempPageSize).Take(20).ToArray();
                Session["test"] = testDatas;


                Session["PageSize"] = tempPageSize;

                break;
            case "OnLast":

 Session["PageSize"] = 20;
                test = CreateTestData();
                testDatas = test.Reverse().Take(20).Reverse().ToArray();
                Session["test"] = testDatas;
                Session["endRecords"] = true;


                break;
        }
    }

 public class TestData
    {
        public string Name { get; set; }
        public string Role { get; set; }
    }

    /// <summary>  
    /// In memory Data source  
    /// </summary>  
    /// <returns></returns>  
    public TestData[] CreateTestData()
    {
        List<TestData> data = new List<TestData>();
        data.Add(new TestData { Name = "Jignesh", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish", Role = "Developer" });
        data.Add(new TestData { Name = "Parth", Role = "Developer" });
        data.Add(new TestData { Name = "Manish", Role = "QA" });
        data.Add(new TestData { Name = "Manisha", Role = "QA" });
        data.Add(new TestData { Name = "Urmi", Role = "QA" });
        data.Add(new TestData { Name = "Bharat", Role = "QA" });
        data.Add(new TestData { Name = "Varun", Role = "QA" });
        data.Add(new TestData { Name = "Komal", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval", Role = "QA" });
        data.Add(new TestData { Name = "Chirag", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid", Role = "QA" });
        data.Add(new TestData { Name = "Vivek", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi", Role = "Architect" });
        data.Add(new TestData { Name = "Denish", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 2", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 2", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 2", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 2", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 2", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 2", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 2", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 2", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 2", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 2", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 2", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 2", Role = "QA" });
        data.Add(new TestData { Name = "Varun 2", Role = "QA" });
        data.Add(new TestData { Name = "Komal 2", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 2", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 2", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 2", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 2", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 2", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 2", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 3", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 3", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 3", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 3", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 3", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 3", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 3", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 3", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 3", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 3", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 3", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 3", Role = "QA" });
        data.Add(new TestData { Name = "Varun 3", Role = "QA" });
        data.Add(new TestData { Name = "Komal 3", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 3", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 3", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 3", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 3", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 3", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 3", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 4", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 4", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 4", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 4", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 4", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 4", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 4", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 4", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 4", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 4", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 4", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 4", Role = "QA" });
        data.Add(new TestData { Name = "Varun 4", Role = "QA" });
        data.Add(new TestData { Name = "Komal 4", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 4", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 4", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 4", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 4", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 4", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 4", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 5", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 5", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 5", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 5", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 5", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 5", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 5", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 5", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 5", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 5", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 5", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 5", Role = "QA" });
        data.Add(new TestData { Name = "Varun 5", Role = "QA" });
        data.Add(new TestData { Name = "Komal 5", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 5", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 5", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 5", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 5", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 5", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 5", Role = "Developer" });

        data.Add(new TestData { Name = "Jignesh 6", Role = "Project Manager" });
        data.Add(new TestData { Name = "Tejas 6", Role = "Architect" });
        data.Add(new TestData { Name = "Rakesh 6", Role = "Lead" });
        data.Add(new TestData { Name = "Hiren 6", Role = "Developer" });
        data.Add(new TestData { Name = "Pooja 6", Role = "Developer" });
        data.Add(new TestData { Name = "Keyur 6", Role = "Developer" });
        data.Add(new TestData { Name = "Ashish 6", Role = "Developer" });
        data.Add(new TestData { Name = "Parth 6", Role = "Developer" });
        data.Add(new TestData { Name = "Manish 6", Role = "QA" });
        data.Add(new TestData { Name = "Manisha 6", Role = "QA" });
        data.Add(new TestData { Name = "Urmi 6", Role = "QA" });
        data.Add(new TestData { Name = "Bharat 6", Role = "QA" });
        data.Add(new TestData { Name = "Varun 6", Role = "QA" });
        data.Add(new TestData { Name = "Komal 6", Role = "QA" });
        data.Add(new TestData { Name = "Dhaval 6", Role = "QA" });
        data.Add(new TestData { Name = "Chirag 6", Role = "Project Manager" });
        data.Add(new TestData { Name = "Devid 6", Role = "QA" });
        data.Add(new TestData { Name = "Vivek 6", Role = "Developer" });
        data.Add(new TestData { Name = "Purvi 6", Role = "Architect" });
        data.Add(new TestData { Name = "Denish 6", Role = "Developer" });

        return data.ToArray();
    }

   private TestData[] GetData()
    {
        if (Session["test"] == null)
        {
            var test = CreateTestData();
            testDatas = test.Take(20).ToArray();
            Session["test"] = testDatas;
        }
        else
            testDatas = (TestData[])Session["test"];
        return testDatas;
    }
   

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