Pages

Men

rh

8/05/2013

Error : Cannot have multiple items selected in a DropDownList in Asp.Net with C#

First of all the Drop down control should be bind using Dataset .

Please find the code below.

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

  {

  if (ddlCountry.Items[i].Text.ToString() == dsCustomer.Tables[0].Rows[0]["CountryName"].ToString().Trim())
                           
        {
              ddlCountry.ClearSelection();
              ddlCountry.Items.FindByText(dsCustomer.Tables[0].Rows[0]["CountryName"].ToString().Trim()).Selected = true;
                             
                          
         }
                     
  }

No comments :

Post a Comment