Hello,
Have u done this as follows
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ToString());
DataTable odt = new DataTable();
DropDownList ddl = new DropDownList();
try
{
sqlCon.Open();
SqlDataAdapter sqlda = new SqlDataAdapter("select * from cState", sqlCon);
sqlda.Fill(odt);
ddl.DataSource = odt;
ddl.DataTextField = "StateName";
ddl.DataValueField = "StateId";
ddl.DataBind();
PlaceHolder1.Controls.Add(ddl);
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
}
}
thanks,
Ajay