如题!! 我现在在repeater 中有一个checkBox 然后我要循环获取到所有checkBox 然后 当checkBox  为true时,就显示一个dropDownList  但是奇怪的事情发生了,当我选择dropdownlist中item的值时,
但是当我点击第二个 checkBox 的时候,第一个dropDownList   选中的值就被刷新掉了, 请教大家了。。

解决方案 »

  1.   

    值被刷掉了,不要再重新绑定资料,并确定在绑定repeater的时候,每个CheckBox对应都有dropDownList ,且其值已经绑定
      

  2.   

    下面是dropDownList 事件 我每次选择的时候可以获取 
    CustomIzation,DateTime, GUID 这三个中的一个值,但是当我再选择checkBox 事件 的时候这选择的值变没了,变成默认值了,不是我之前所选中的值。protected void ddlType_IndexChange(object sender, EventArgs e)
            {
                foreach (RepeaterItem rptItem in rptSource.Items)
                {
                    DropDownList ddlType = (DropDownList)rptItem.FindControl("ddlType");
                    TextBox txtValue = (TextBox)rptItem.FindControl("txtValue");
                    if (ddlType.Visible == true) 
                    {
                        if (ddlType.SelectedValue == "CustomIzation")
                        {
                            txtValue.Visible = true; //如果值类型选中为CustomIzation就让文本框显示
                            hidType.Value = ddlType.SelectedItem.Value;
                        }
                        else if (ddlType.SelectedValue == "DateTime")
                        {
                            txtValue.Visible = false;
                            hidType.Value = ddlType.SelectedItem.Value;
                        }
                        else if (ddlType.SelectedValue == "GUID")
                        {
                            txtValue.Visible = false;
                            hidType.Value = ddlType.SelectedItem.Value;
                        }
                    }
                }