C# CheckBoxList-DropDownList回显、筛选回显

 <asp:CheckBoxList ID="ddlType" runat="server" RepeatColumns="10" RepeatDirection="Horizontal"></asp:CheckBoxList>
 
 string ctypes = Convert.ToString(dtPtsDetail.Rows[0]["Type1"]);

                string[] arr = ctypes.Split(',');
                for (int c = 0; c < arr.Length - 1; c++)
                {
                        ddlType.Items.Add(arr[c]);
                   
                }
                
                foreach (string ar in arr)
                {
                    foreach (ListItem itc in ddlType.Items)
                    {
                        if (ar == itc.Value)
                            itc.Selected = true;
                        else
                            continue;
                    }
                   
                }

<asp:DropDownList ID="ddlType" runat="server"  AutoPostBack="true" ></asp:DropDownList>
				
 string ctypes = Convert.ToString(dtPtsDetail.Rows[0]["Type1"]);

                string[] arr = ctypes.Split(',');
               
                         ddlType.SelectedIndex = ddlType.Items.IndexOf(ddlType.Items.FindByValue(arr[0]));
                   
                
				

  

posted @ 2021-09-06 10:45  刘贵庆  阅读(94)  评论(0编辑  收藏  举报