I'm trying to populate an ASPropDownList on PageLoad using a C# script. I would like the DropDownList to be created using an array of objects, but it's not working and I'm at a loss for how to proceed.
Here's the code for the dropdownlist in sc2.aspx
Here's the code for the script in sc2.aspx.cs
And finally, here is some of the appropriate code from my SellingCompany class.
Can you guys make any suggestions?
PS - If I've made any really obvious, newbie mistakes, I apologise. I've only been working with C# for about a week, and this is my first dive into ASP.
-------------------------
Just call me Captain Awesome.
Here's the code for the dropdownlist in sc2.aspx
Code:
<asp:DropDownList ID="ddlSellingCompanies" runat="server" />
Here's the code for the script in sc2.aspx.cs
Code:
protected void Page_Load(object sender, EventArgs e)
{
getCompanies();
}
private string getCompanies()
{
//Here, I get an array of SellingCompanies called companies
if (companies != null)
{
ddlSellingCompanies.DataSource = companies;
ddlSellingCompanies.DataTextField = "Name";
ddlSellingCompanies.DataValueField = "ID";
}
return content;
}
And finally, here is some of the appropriate code from my SellingCompany class.
Code:
public string ID
{
get { return _ID; }
set { _ID = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
Can you guys make any suggestions?
PS - If I've made any really obvious, newbie mistakes, I apologise. I've only been working with C# for about a week, and this is my first dive into ASP.
-------------------------
Just call me Captain Awesome.