M
Microsoft News Group
I am populating a dropdown list from a DB Table and cannot get the list to
populate! Can anyone see what I am missing? I am telling the dropdownlist to
use 2 fields from the record set, then from the codebehind I am pushing the
dataset to the dropdownlist.
Thoughts?
<aspropDownList id="ivState" runat="server" DataTextField="State"
DataValueField="ST_Abbrev"></AspropDownList>
private void loadStates()
{
OleDbConnection stconn = null;
OleDbDataReader streader = null;
try
{
string indexTable = "tblStates";
stconn = new OleDbConnection(Configuration.pdsConnectionString);
stconn.Open();
string stquery = "SELECT State, ST_Abbrev, Meridian_Name, N_Max, S_Max,
E_Max, W_Max FROM " + indexTable;
OleDbCommand cmd = new OleDbCommand(stquery, stconn);
streader = cmd.ExecuteReader();
ivState.DataSource = streader;
ivState.DataBind();
}
catch (Exception e)
{
#region ErrorCode
Response.Write("<BR>");
Response.Write(e.Message);
Response.End();
#endregion
}
finally
{
if (streader != null) streader.Close();
if (stconn != null) stconn.Close();
}
}
populate! Can anyone see what I am missing? I am telling the dropdownlist to
use 2 fields from the record set, then from the codebehind I am pushing the
dataset to the dropdownlist.
Thoughts?
<aspropDownList id="ivState" runat="server" DataTextField="State"
DataValueField="ST_Abbrev"></AspropDownList>
private void loadStates()
{
OleDbConnection stconn = null;
OleDbDataReader streader = null;
try
{
string indexTable = "tblStates";
stconn = new OleDbConnection(Configuration.pdsConnectionString);
stconn.Open();
string stquery = "SELECT State, ST_Abbrev, Meridian_Name, N_Max, S_Max,
E_Max, W_Max FROM " + indexTable;
OleDbCommand cmd = new OleDbCommand(stquery, stconn);
streader = cmd.ExecuteReader();
ivState.DataSource = streader;
ivState.DataBind();
}
catch (Exception e)
{
#region ErrorCode
Response.Write("<BR>");
Response.Write(e.Message);
Response.End();
#endregion
}
finally
{
if (streader != null) streader.Close();
if (stconn != null) stconn.Close();
}
}