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:
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!