Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8081001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:35:16+00:00 2026-06-05T16:35:16+00:00

I need to display all the employees in one webpart. I created the gridview

  • 0

I need to display all the employees in one webpart. I created the gridview and attached the data by iterating through all the users in SharePoint. After that they asked me to add paging and I added our normal paging at the bottom. Now they want the paging in alphabetical order..

I need to display all the user name starting from “A” when Clicked on “A” and so on… I need to add both alphabetical paging and numeric paging…

I searched through google but to no avail.. can anyone help me with this?? Is it javascript/code behind…and how to incorporate the search function….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:35:18+00:00Added an answer on June 5, 2026 at 4:35 pm
    Method 1: Create Pager with Alphabets from A-Z 
    
    
    **Aspx Page**
    
    Open an aspx page in your Visual Studio, add a DataList and a GridView control into it. The DataList control is the Pager control, used to display the Page Numbers, in our terms Paging Alphabets and the GridView control is used to display the list of customers from the SQL Server database. First, in the Item Template section of the DataList, add a LinkButton and name it as lnkbtnPaging. Bind the Text and CommandArgument property of the LinkButton with the value as PageText and PageIndex respectively. PageText and PageIndex are the two columns from the DataTable, which we are going to create in the code-behind section to bind with this DataList. This DataTable will have values used for paging. Note that both PageText and PageIndex will have the same value. Then design the GridView control to display columns from the Employee table. 
    
     <asp:DataList ID="DataList1" OnItemCommand="DataList1_ItemCommand"
                OnItemDataBound="DataList1_ItemDataBound" RepeatDirection="Horizontal" runat="server">
    
            <SeparatorTemplate>
    
                </SeparatorTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="lnkbtnPaging" runat="server" CommandArgument='<%# Bind("PageIndex") %>'
                        Text='<%# Bind("PageText") %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:DataList>
    
            <br />
    
            <asp:GridView ID="GridView1" runat="server" EmptyDataText="No Records Found">
            </asp:GridView>
    
    
    
    **Aspx.cs file**
    
    The first method is to create an alphabetical paging control with alphabets from A to Z. For this we have to loop through 65 to 90, and convert the value to its equivalent character, which is from A to Z. Then store each value into a DataTable row and bind it with the DataList control. The code for this method is given below
    
     private void CreateAlphaPagings()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("PageIndex");
            dt.Columns.Add("PageText");
            if (this.ViewState["Paging"] == null)
            {
                for (int i = 65; i <= 90; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = Char.ConvertFromUtf32(i);
                    dr[1] = Char.ConvertFromUtf32(i);
                    dt.Rows.Add(dr);
                }
                DataRow drNew = dt.NewRow();
                drNew["PageIndex"] = "All";
                drNew["PageText"] = "All";
                dt.Rows.Add(drNew);
                this.ViewState["Paging"] = dt;
            }
            else
                dt = (DataTable)this.ViewState["Paging"];
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
    
    The above method creates a DataTable with two columns PageIndex and PageText. We loop through 65 to 90, whose ASCII character equivalent is from A to Z. We are using Char.ConvertFromUtf32 method to convert the number to alphabets. After conversion we assign the value to the PageIndex and PageText columns of the DataTable. Sometimes, the user needs to view all the data in a single page. To provide this option we have added another DataRow with value “All”. We have also used a ViewState variable in this method, in order to avoid the for-loop being executed every time this method is called. So for the first time, when the page loads, the ViewState is empty or null, thus execute the for-loop to create the rows for the DataTable, then the DataTable created will be stored in the ViewState called “Paging”. When this method is called subsequently, the ViewState “Paging” it will supply the alphabetical paging DataTable rows. Finally we bind the DataList is bind with the paging DataTable
    
    **Bind the GridView control** 
    
    To display the Customer information in a GridView control, we create a method called BindGrid, which takes a parameter called StartAlpha. This parameter is responsible to filter the customer records before binding it with the GridView control. If the parameter value is “All”, then all records will be displayed in the GridView control. The BindGrid method is given below.
    
      private void BindGrid(string StartAlpha)
        {
            string sql = "";
            if (StartAlpha == "All")
                sql = "Select ecode,firstName from sales_employee Order By Ecode Desc";
            else
                sql = "Select ecode,firstName from sales_employee Where firstName Like '" + StartAlpha
                    + "%' Order By Ecode Desc ";
    
            string strConnection = "Your Connection String";
    
            con.ConnectionString = strConnection;
    
                 con.Open();
                SqlDataAdapter adp = new SqlDataAdapter(sql,con);
                DataSet ds = new DataSet();
                adp.Fill(ds);
                GridView1.DataSource = ds;
                GridView1.DataBind();
    
        }
    
    **Page Load Event** 
    
      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.ViewState["SelectedText"] = "All";
                CreateAlphaPagings();
                BindGrid(this.ViewState["SelectedText"].ToString());
            } 
    
    
        }
    **DataList ItemCommand Event** 
    
    
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            LinkButton lbkbtnPaging = (LinkButton)e.CommandSource;
            BindGrid(e.CommandArgument.ToString());
            this.ViewState["SelectedText"] = e.CommandArgument.ToString();
            CreateAlphaPagings();
        }
    
    **DataList ItemDataBound Event** 
    
    
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem
              || e.Item.ItemType == ListItemType.Item)
            {
                if (this.ViewState["SelectedText"] != null)
                {
                    LinkButton lbkbtnPaging = (LinkButton)e.Item.FindControl("lnkbtnPaging");
                    if (this.ViewState["SelectedText"].ToString() == lbkbtnPaging.Text)
                        lbkbtnPaging.Enabled = false;
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display all enum values as tab items on TabControl, except one
I need to display all the pages on the one page. At the moment
With the new Cookie regulation, like all of us I need to display a
i am developing one application with map view i need display the weather depends
I need to display image and one button on fancybox popup but I can't
I need to display short description like label and near it data associated with
I need to display a multiply sign (×) in a modal being created by
I need to display a UI element (e.g. a star or checkmark) for employees
I need to display all tables that have zero records. I tried, select *
I need to display all my post titles in the sidebar of my Wordpress

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.