G
Guest
Hi,
I am trying to get a DropDownList to be populated by a simple query, but I
cannot see why it doesn't work, I was hoping someone can shed some light for
me.
Here's my C# code:
private void Page_Load(object sender, System.EventArgs e)
{
//strConn = ConfigurationSettings.AppSettings["SqlConnect"];
DataSet ds = new DataSet();
DataView dv = new DataView();
SqlConnection objConn = new
SqlConnection(ConfigurationSettings.AppSettings["SqlConnect"]);
SqlDataAdapter myDataAdapter = new SqlDataAdapter("SELECT RSL, FullName
FROM tbl_Contacts_2005", objConn);
myDataAdapter.Fill(ds, "RSLNames");
dv = ds.Tables["RSLNames"].DefaultView;
ddlRSL.DataSource = dv;
ddlRSL.DataValueField = "RSL";
ddlRSL.DataTextField = "FullName";
ddlRSL.DataBind();
}
And heres my DropDownList tag:
<aspropDownList id="ddlRSL" runat="server" />
I cannot see why it doesn't work.
Any ideas?
I am trying to get a DropDownList to be populated by a simple query, but I
cannot see why it doesn't work, I was hoping someone can shed some light for
me.
Here's my C# code:
private void Page_Load(object sender, System.EventArgs e)
{
//strConn = ConfigurationSettings.AppSettings["SqlConnect"];
DataSet ds = new DataSet();
DataView dv = new DataView();
SqlConnection objConn = new
SqlConnection(ConfigurationSettings.AppSettings["SqlConnect"]);
SqlDataAdapter myDataAdapter = new SqlDataAdapter("SELECT RSL, FullName
FROM tbl_Contacts_2005", objConn);
myDataAdapter.Fill(ds, "RSLNames");
dv = ds.Tables["RSLNames"].DefaultView;
ddlRSL.DataSource = dv;
ddlRSL.DataValueField = "RSL";
ddlRSL.DataTextField = "FullName";
ddlRSL.DataBind();
}
And heres my DropDownList tag:
<aspropDownList id="ddlRSL" runat="server" />
I cannot see why it doesn't work.
Any ideas?