Posted on: 10/29/2012 1:24:20 AM | Views : 213

Thanks for viewing my post. I have a web form with DropDownList and many textboxes completed in C#. I also have a database in SQL with SUPPLIER table. how i can choose the the supplier id from the Dropdownlist , then showing the relevant data in text boxes.
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
bindtoddl();
}

}
private void bindtoddl()
{
string theSqlServer = ConfigurationManager.ConnectionStrings["theSqlServer"].ConnectionString;
SqlConnection con = new SqlConnection(theSqlServer);
SqlCommand cmd = new SqlCommand("select * from Supplier", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "SAccNo"; // FieldName of Table in DataBase
DropDownLis ...

Go to the complete details ...