Pages

Men

rh

8/05/2013

How to assign a value to a Drop down list from Dataset in Asp.net with C#

Make Sure you already bind a Dropdown control..

 for (int i = 0; i < ddlCountry.Items.Count; i++)
  {

     if (ddlCountry.Items[i].Text.ToString() == dsCustomer.Tables[0].Rows[0]["CountryName"].ToString().Trim())

        {

           ddlCountry.Items.FindByText(dsCustomer.Tables[0].Rows[0]["CountryName"].ToString().Trim()).Selected = true;

         }

 }




No comments :

Post a Comment