效果如图, 如果点击主键的checkBox 那么这死将做为主键, 在下面会有一个完成按钮
点击按钮的时候 要做这么几个操作,
(1)第一要判断 checkBox有没有被选中, 这步没问题循环repeater 然后获取到这个控件,
 (2) 就是要将左边字段的值丛数据库读取出来,
(3)插入到右边dropDownList的字段中, 
 最后一步最麻烦, 就是在插入的同时要判断 右边下拉框字段中有没有这些数据,如果有则更新,没有则新增。。 搞了我二天也做不出来求求大家帮心看下拉!! 只要能解决多少分我可以再加。。  List<string> listSource = null;
        List<string> listTarget = null;
        if (this.hdfSource.Value != null)
        {
            //第一步获取源主键的值
            listSource = dc.SelectInfoBy_FK(selectSourceTable, conSourceStr, this.hdfSource.Value);
        }
        if (this.hdfTarget.Value != null)
        {
            //第二步获取目标主键的值
            listTarget = dc.SelectInfoBy_FK(selectTargetTable, conServiceStr, this.hdfTarget.Value);
        }
        //插入之前要先判断目标有没有这条信息如果有,则更新,否则插入
        if (listSource != null)
                {
                    foreach (string source in listSource)
                  {
                        if (listTarget != null)
                        {
                           if (listTarget.Contains(source))
                           {
                               //调用更新方法
                               string columns = JoinColumns(dicPare, selectTargetTable);
                               string sql = JoinParameter(dicPare, "3");
                               InsertMethod(dicPare, selectSourceTable, sql);
                           }
                         else
                            {
                                string columns = JoinColumns(dicPare);//获取列
                                string param = JoinParameter(dicPare);//获取要更新的参数   这里是拼接SQL字符串
                                string sql = " INSERT INTO " + selectTargetTable + " (" + columns + ") VALUES (" + param + ")";
                               InsertMethod(dicPare, selectSourceTable, sql);
                           }
                       }
                     }

解决方案 »

  1.   

    DropDownList1.Items.FindByValue("")判断是否存在
      

  2.   

    定义一个结构体
    struct TData
    {   
        string str;
        int   nItem; //对应界面控件的Item ID
    }List <TData> listSource = null; 
    List <TData> listTarget = null; 
      

  3.   

    也就是说 你的dropdownlist的Source是取自checkbox的值
    然后根据dropdownlist的selectedvalue再去库里面捞数据
    这样的话
    你先循环 checkbox 拿到勾选的所有值
    然后填充dropdownlist 的Source 就可以了啊
    dropdownlist 好像本身就不允许出现相同的值吧