datagrid下 选中多条列号相同的记录进行修改 并将相应修改更新到数据库.
  举例:选中多行记录,1)如果在选中的记录中,房间号(列名)都相同,则点击修改房间号后,选中的行房间号是1的 自动修改为2;房间号为2的 自动修改为1 
                     并寻找到对应房客NAME在数据库中进行更新保存
                     2)如果在选中的记录中,房间号(列名)不同,则提示messagebox.show("请选择相同房间号进行修改操作")
       
                for (int i = 0; i < tb.Rows.Count; i++) //tb是我建的一datatable
                {
                    if ((bool)tb.Rows[i]["选中"])
                    {
                        this.ultraGrid1.Rows[i].Selected = true;
                    }
                }
                foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Selected.Rows)
                {
                    int index = row.Index;
                    if (int.Parse(tb.Rows[index]["房间号"].ToString()) == 1)
                    {
                        rno = "2";
                        personName = tb.Rows[index]["房间号"].ToString();   //
                    }
                    else if (int.Parse(tb.Rows[index]["房间号"].ToString()) == 2)
                    {
                        rno = "1";
                        personName = tb.Rows[index]["房间号"].ToString();
                    }
                }
                string str = "UPDATE information SET roomNO='" + rno + "' WHERE personName='"+personName+"'";
                JL_HRM.Class_main.ExcuteSQL(str);上面是我设计的对选中单行记录进行操作的代码,成功;  现在是我要进行多行选择判断并进行操作,要求如开始,如何编写,请帮忙谢谢,在线等

解决方案 »

  1.   


     function ShowAllItemsChecked()
           {
             var chkbox=document.getElementsByTagName("input");
             var chkChecked=document.getElementById("chkAllItems");
             for(var i=0;i<chkbox.length;i++)
              {
                var temp=chkbox.item(i);
                if(temp.type=="checkbox" && temp.id!="chkAllItems")
                   {
                     temp.checked=chkChecked.checked;
                     ItemValues=ItemValues+temp.value+',';
                   }
              }
          }
      

  2.   

    把更新的过程写到foreach里面不就行了么?虽然很委琐...