Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am dynamically creating Menuitems.
ASP.NET
<asp:Menu ID="menuNumeric" runat="server" CssClass="pagerFont" Orientation="Horizontal" OnMenuItemClick="menuNumeric_Click" Visible="true">                                                            

C#
//code file
protected void grVwProductionOrderSearch_OnDataBound(object sender, EventArgs e)
    {
        Menu menuNumeric = (Menu)PagerPO.FindControl("menuNumeric");
        menuNumeric.Items.Clear();


        int startIndex = ((PagerCurrentIndex / PagerDisplayCount) * PagerDisplayCount) + 1;
        int maxIndex = startIndex + PagerDisplayCount;

        for (int i = startIndex; i < maxIndex; i++)
        {
            MenuItem item = new MenuItem();
            item.Text = " " + i.ToString() + " ";
            item.Value = i.ToString();

            if (grVwProductionOrderSearch.PageIndex == i)
            {
                item.Selected = true;
                PagerCurrentIndex = i;
            }
            menuNumeric.Items.Add(item);

        }
    } 


There is no space between menuitems
output: 12345678910

How to add space between menuitems
expected output: 1 2 3 4 5 6 7 8 9 10

Thank you
Posted
Updated 13-Oct-11 20:44pm
v2

1 solution

One naive but working approach: insert one or more &nbsp; characters (non-breakable space) between each pair of items.

Another approach is: sandwich each in span tag, possibly with class attribute. In CSS, give this spam element some margin-left or margin-right, or better both, symmetrically. Instead of span you can use any inline HTML element.

—SA
 
Share this answer
 
v5
Comments
swathi.N 14-Oct-11 3:02am    
I am appending "non breaking space" to item.text property item.Text = i.ToString() + "non breaking space";. This is not working,What i did is right know

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