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 9193723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:13:53+00:00 2026-06-17T21:13:53+00:00

i like to have 2 columns in my drop down list with specific distance

  • 0

i like to have 2 columns in my drop down list with specific distance between 2 columns, so i have added below code but columns are not align with my code.

var query = from p in _DataContext.tblDocuments
                    orderby p.DocumentNo

                    select new
                    {
                        Doctitle = p.DocumentNo+' '+' '+"|"+' '+p.TITLE,
                        DocId = p.DocId
                    };
        ddlProjectDocument.DataSource = query;
        ddlProjectDocument.DataValueField = "DocId";
        ddlProjectDocument.DataTextField = "Doctitle";
        ddlProjectDocument.DataBind();

please help how i can have 2 columns with normal view and good align.

  • 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-17T21:13:54+00:00Added an answer on June 17, 2026 at 9:13 pm

    The alignment will depend on the length of the value in the field of your table. One way to do it would be to get the size of the largest entry in your table and make sure that all entries are that wide. Here is something you can try.

      <asp:DropDownList ID="ddlStack" runat="server" OnLoad="ddlStack_Load" />
    

    and in the source code for ddl load event:

      protected void ddlStack_Load(object sender, EventArgs e)
      {
            var all = from o in _DataContext.tblDocuments
                      orderby o.DocumentNo
                      select o;
            int maxs = 0;
            foreach (tblDocuments v in all)
            {
                if (v.DocumentNo.Length > maxs)
                    maxs = v.DocumentNo.Length;
            }
    
    
    
            foreach (tblDocuments vv in all)
            {
                string doctitle = vv.DocumentNo;
                for (int i = vv.DocumentNo.Length; i < maxs + 2; i++)
                {
                    doctitle += '_';
    
                }
                doctitle += " | ";
                doctitle +=  vv.DocID;
                ddlStack.Items.Add(new ListItem(doctitle, vv.vendorID.ToString()));
    
    
            }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several columns that I'd like to search against. My code might not
I have two columns A and B, and would like to get a list
I have read tutorials about how to populate an entire Drop down list with
Lets say I have a drop down list and a grid view on a
I have a table products , and I have columns like product_name , product_id
I have several columns in a MySQL database that I would like to add
I have 2 columns in a table and I would like to roughly report
In my table accounts I have four columns like user, pass, column1, column2 I
I have a table like T1 with columns C1 and C2. I have the
I have a table structure with columns like this [ID] [Name] [ParentId] [ParentName] The

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.