[...]
public DataSet ReturnPromoMagazinesDs()
{
MySql.Data.MySqlClient.MySqlConnection mysqlConnection = new MySql.Data.MySqlClient.MySqlConnection(this.connectionString);
MySql.Data.MySqlClient.MySqlCommand mysqlCommand = new MySql.Data.MySqlClient.MySqlCommand("SELECT id, magazine_name FROM `magazines`", mysqlConnection);
MySql.Data.MySqlClient.MySqlDataAdapter mysqlAdaptor = new MySql.Data.MySqlClient.MySqlDataAdapter(mysqlCommand);
DataSet ds = new DataSet();
mysqlAdaptor.Fill(ds, "magazines");
return ds;
}
[...]
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds = coreObject.ReturnPromoMagazinesDs();
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = ds.Tables["magazines"].Columns["magazine_name"].ColumnName;
DropDownList1.DataValueField = ds.Tables["magazines"].Columns["id"].ColumnName;
DropDownList1.DataBind();
}
[...]
<asp:dropdownlist id="DropDownList1" runat="server"></asp:dropdownlist>
The above code works ok, untill I'm fetching the DropDownList1.SelectedValue which is always 1 (the fist value from the table). Values in the table aren't the blame for this, and if I manually add items to the DropDownList, everything works fine. What can cause this?