Dropdownlist for, selection options text (from database) becomes vertically single letter using C# razor

233 Views Asked by At

I'm trying to create a drop down list for from a dataset column in my SQL Server database. I have successfully linked the data. However, in view, the dropdown list data appears to have a vertically text.

Please see the screen captured below:

As you cab see the captured image the list becomes vertically with single letter becomes an option select

This is the store procedure, which the dropdown list option should show

What causes this? Please help!

I'm just going to post the relevant code to easy to see.

Here is the line of the html code (I put index 0 for savedCompCoList for testing only to only get the first row):

<div>@Html.DropDownListFor(x => x.objBV.objCompCo.SavedCompCoSelected, new SelectList(Model.objBV.objCompCo.SavedCompCoList[0].CompCo_ID_With_date_List), "Select List", new { style = "width: 250px;" }))</div>

Using xmlDocument for connection to database:

public static XmlDocument GetSavedCompCo()
{
    XmlDocument xmlTmp = DatabaseLib.RunStoredProcedure(UDV.spGetSavedCompCoListBV, UDV.connStringUserDB);
  
    return xmlTmp;
}

Using Web method:

[WebMethod]
public XmlDocument GetSavedCompCo() { return BDOLibrary_Val_BV.CompsLib.GetSavedCompCo(); }

My model - here is the loop that loop though (this may be the cause):

public class CompCo
{
        private readonly BDOWebService.BDOWebService webS = new BDOWebService.BDOWebService(); //EC: web service

        //EC: variables
        public List<SavedCompCo> SavedCompCoList { get; set; }
        public int SavedCompCoSelected { get; set; }

        public CompCo()
        {
            initSavedCompCoList();
            Comps = new List<Company>();
        }

        private void initSavedCompCoList()
        {
            SavedCompCoList = new List<SavedCompCo>();
            XmlDocument xmlTmp = webS.GetSavedCompCo();

            XmlNodeList nodeListSavedCompCo_ID_With_Date = xmlTmp.GetElementsByTagName("CompCo_ID_With_Date");

            for (int i = 0; i < nodeListSavedCompCo_ID_With_Date.Count; i++)
            {
                SavedCompCo SavedCompCoTemp = new SavedCompCo();
                SavedCompCoTemp.CompCo_ID_With_date_List = nodeListSavedCompCo_ID_With_Date[i].InnerText.Trim();

                SavedCompCoList.Add(SavedCompCoTemp);
            }
    
        }
}

Please help and thanks in advance!

0

There are 0 best solutions below