C# 我想在每次单击重置按钮时将Dropdownlist值设置为默认值(例如:选择)

C# 我想在每次单击重置按钮时将Dropdownlist值设置为默认值(例如:选择),c#,C#,嗨,我的应用程序中有一个下拉列表。 我想要的是每次单击重置按钮时,它都应设置为默认值(选择) 这是我的重置代码 public void ResetControl() { DDLContainer.SelectedIndex = 0; DDLCountryLoading.SelectedIndex = 0; DDLCountryDestination.SelectedIndex = 0;

嗨,我的应用程序中有一个下拉列表。 我想要的是每次单击重置按钮时,它都应设置为默认值(选择)

这是我的重置代码

public void ResetControl()
        {
            DDLContainer.SelectedIndex = 0;
            DDLCountryLoading.SelectedIndex = 0;
            DDLCountryDestination.SelectedIndex = 0;
            //DDLContainer.Items.Insert(0, new ListItem(" --SELECT--", "0"));
           ImageMode.ImageUrl = "~/ShowImageMode.ashx?Mode=A";
        }
这是我的下拉列表代码:

void ddlCountry()
        {
            con.Open();
            cmd = new SqlCommand("select Distinct(mCRY_VCName) from TB_TransCountry", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            DDLCountryLoading.DataSource = ds;
            DDLCountryLoading.DataSourceID = String.Empty;
            DDLCountryLoading.DataTextField = "mCRY_VCName";
            DDLCountryLoading.DataValueField = "mCRY_VCName";
            DDLCountryLoading.DataBind();

            DDLCountryLoading.Items.Insert(0, new ListItem(" --SELECT--", "0"));

            DDLCountryDestination.DataSource = ds;
            DDLCountryDestination.DataSourceID = String.Empty;
            DDLCountryDestination.DataTextField = "mCRY_VCName";
            DDLCountryDestination.DataValueField = "mCRY_VCName";
            DDLCountryDestination.DataBind();

            DDLCountryDestination.Items.Insert(0, new ListItem(" --SELECT--", "0"));
            con.Close();


        }
        void ddlContainer()
        {
            con.Open();
            cmd = new SqlCommand("select Distinct(mCNT_VCTypeName) from TB_TransContainerType", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            DDLContainer.DataSource = ds;
            DDLContainer.DataSourceID = String.Empty;
            DDLContainer.DataTextField = "mCNT_VCTypeName";
            DDLContainer.DataValueField = "mCNT_VCTypeName";
            DDLContainer.DataBind();

            DDLContainer.Items.Insert(0, new ListItem(" --SELECT--", "0"));


            con.Close();


        }
有谁能帮我做到这一点吗

试试这个
DDLContainer.Items[0]。所选内容=true

您有重置方法,因此可以通过设置从-1开始的SelectedIndex来设置索引,也可以使用selectedValue属性并设置该值