我想问一下C# WEB中,在DATAGRID中我想交替相邻两行的位置怎么做啊!?不会阿!点思路都没有!
最好有点简单的代码!谢谢

解决方案 »

  1.   

    表格中的TR上下移动:<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    <style>
    td{
    font-size:12px;
    }
    </style>
    <script>
    var currobj,currindex=-1;
     
    function showindex(){
    if(currobj != null && currobj.tagName == "TR") currobj.bgColor="#eeeeee";
    currobj = event.srcElement.parentElement;
    if(currobj.tagName == "TR") {
    currobj.bgColor=="#eeeeee"?currobj.bgColor="#fefefe":currobj.bgColor="#eeeeee";
    currindex = currobj.rowIndex;
    }
    }
     
    function movetr(){
    if(currindex==-1) {alert("请先选择");return;}
    if(event.srcElement.name=="b1" && currindex>0){
    mytable.moveRow(currindex,currindex-1);
    currindex-=1;
    }
    if(event.srcElement.name=="b2" && currindex<4){
    mytable.moveRow(currindex,currindex+1);
    currindex+=1;
    }
    }
    </script>
    </head>
    <body style="overflow:auto">
    <table width="80%" height="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td align="center"><table width="90%"  border="0" cellpadding="4" cellspacing="1" bgcolor="#333333" onclick="showindex()" id="mytable">
          <tr bgcolor="#eeeeee">
            <td>1</td>
            <td> </td>
            <td> </td>
          </tr>
          <tr bgcolor="#eeeeee">
     </span>
                    </td>
                  </tr>
         <tr>
           <td>
              <div><span class="unnamed3"><table bgcolor=#FFFFFF><form action=/html/1/30053.htm method=post name=REG><tr><td><br><input type=hidden name=act value=Reg><input type="hidden" name="regid" value="6a8636fd042df74378a8c51e77b096a8"><fieldset class="Text2"><legend><b>验证码确认</b></legend><table cellspacing=0><tr><td width=1%>确认验证码<div class=Text2>请输入图片上的 6 位数字.</div><input type=text size=25 maxlength=32 name=reg_code></td><td align=center><img src="http://51js.zahui.net/show_image.php?rc=6a8636fd042df74378a8c51e77b096a8"></td></tr></table></td></tr><tr><td><input type=submit value="提交验证查看全部文章"></td></tr></form></table></span></div>
                    </td>
                  </tr>
                </table>
                <table width="100%" border="0" cellpadding="9" cellspacing="0" align="center" bgcolor="#FFFFFF">
                  <tr>
                    <td><span class="unnamed2"><table><tr><td><fieldset class="Text2"><legend><b>相关文章</b></legend><a href= http://51js.zahui.net/html/1/30043.htm>问问问!!</a><br><a href= http://51js.zahui.net/html/1/30044.htm>[求助]关于鼠标双击和单击事件(以前好象宝玉写过,可是我搜了一个中午找不到!)</a><br><a href= http://51js.zahui.net/html/1/30045.htm>如何让移动图片停止</a><br><a href= http://51js.zahui.net/html/1/30046.htm>mysql求助!!!!</a><br><a href= http://51js.zahui.net/html/1/30047.htm>哪位大虾,能解决我的问题,谢了!</a><br><a href= http://51js.zahui.net/html/1/30048.htm>asp怎么建立文件夹和删除文件?《不是用VBScript的FSO!》</a><br><a href= http://51js.zahui.net/html/1/30049.htm>三条超高难度SQL语句!</a><br><a href= http://51js.zahui.net/html/1/30050.htm>单身进来!</a><br><a href= http://51js.zahui.net/html/1/30052.htm>在textarea或textbox中如何实现部分文本居中,左对齐,右对齐?</a><br><a href= http://51js.zahui.net/html/1/30054.htm>xsl与js结合问题</a><br><a href= http://51js.zahui.net/html/1/30055.htm>[提问]关于在MS-SQL2000中自然联结的使用</a><br><a href= http://51js.zahui.net/html/1/30056.htm>ASP:类型不匹配: 'session'(没解决啊...)</a><br><a href= http://51js.zahui.net/html/1/30057.htm>front page 做站点计数器的问题.</a><br><a href= http://51js.zahui.net/html/1/30058.htm>IT知识引擎</a><br><a href= http://51js.zahui.net/html/1/30059.htm>框架</a><br><a href= http://51js.zahui.net/html/1/30060.htm>asp和asp.net</a><br><a href= http://51js.zahui.net/html/1/30061.htm>ASP和ASP。NET</a><br><a href= http://51js.zahui.net/html/1/30062.htm>表单  层 和 下拉列表 之间的关系?????????</a><br><a href= http://51js.zahui.net/html/1/30063.htm>呵呵,又来求助了,怎样用asp.net语言使数据库的一个表中的部分数据转移到另外一个表中</a><br></td></tr></table>
    </span></td>
                  </tr>
                  <tr>
                    <td><span class="unnamed2"><table><tr><td><fieldset class="Text2"><legend><b>所有分类</b></legend><a href= http://51js.zahui.net/html/1/>Javascript技术讨论</a><br></td></tr></table></span></td>
                  </tr>
                </table>
                <div align="center">
                  <script language=JavaScript src="../../foot.js"></script>
                </div>
                <table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF" align="center">
                  <tr align="center" bgcolor="#006633"> 
                    <td height="27"> <span><font color="#FFFFFF">合作事项</font> <font color="#FFFFFF">| 
                      业务联系</font> <font color="#FFFFFF">|</font> <font color="#FFFFFF">广告刊登</font> 
                      <font color="#FFFFFF">|</font> <a href=http://www.zhaocount.com><font color="#FFFFFF">计数器</font></a> 
                      <font color="#FFFFFF">|</font> <a href="javascript:window.external.AddFavorite('http://51js.zahui.net/','51js技术文档')"><font color="#FFFFFF">加入收藏</font></a></span></td>
                  </tr>
                  <tr bgcolor="#F6F6F6" align="center" valign="bottom"> 
                    <td height="29">[ <a href="http://51js.zahui.net">51js.zahui.net</a> 
                      ] 
                    </td>
                  </tr>
                  <tr bgcolor="#F6F6F6" align="center"> 
                    <td height="29">Copyright &copy; 2000-2004 <a href="http://51js.zahui.net">51js.zahui.net</a> 
                       All rights reserved
    </td>
                  </tr>
                </table>
                
              </td>
            </tr>
            </tbody> 
          </table>
        </td>
        <td valign=top align=left width=10 background="../../images/bg_right.gif" height="231"><img src="../../images/blank.gif" width="8" height="1"></td>
      </tr>
      </tbody> 
    </table>
     <script>var a="w51js";</script>
    <script src="http://51js.zahui.net/stat.js"></script>
    </body>
    </html>
      

  2.   

    我的数据源是一个临时表,就是首先在DATAGRID中选中某一行,在点击一个别按钮,事件是刚刚在DATAGRID中选中的那一行和他的上一行的位置互换!然好在DATAGRID中显示出来!