就是我有一个导航栏 是由datalist动态生成的  我想让用户去控制 哪个显示在前面哪个显示在后面 而其能够将这个顺序保存起来 设定好后 以后都按这个顺序显示 该怎么做能给个思路吗?大概给我讲讲思路

解决方案 »

  1.   

    1.  用js控制前台显示
    2.  排序Datalist的数据源
      

  2.   

    那有什么好办点的?我就是想要一个动态显示的导航栏  不用datalist也行 就是要求导航栏里的内容是从数据库读出的 ,读出的个数(也就是导航栏中显示的个数)也不是固定的  
      

  3.   

    create table tb(tid int)
    insert into tb values(0)
    insert into tb values(1)
    insert into tb values(2)
    insert into tb values(3)
    insert into tb values(4)
    insert into tb values(5)
    insert into tb values(6)
    insert into tb values(7)
    insert into tb values(8)
    insert into tb values(9)
    insert into tb values(10)
    insert into tb values(11)
    insert into tb values(12)
    goselect m.tid from
    (
    select * , px = (select count(1) from tb where tid < t.tid) + 1 from tb t
    ) m,
    (
    select * , px = (select count(1) from tb where tid < t.tid) + 1 from tb t
    ) n
    where n.tid =3 and abs(m.px - n.px) =1 --找到当前ID的前后或一条数据
    order by m.tid
    select m.tid from
    (
    select * , px = (select count(1) from tb where tid < t.tid) + 1 from tb t
    ) m,
    (
    select * , px = (select count(1) from tb where tid < t.tid) + 1 from tb t
    ) n
    where n.tid =3 and m.px - n.px=1 --找到当前ID的后条数据
    order by m.tidselect m.tid from
    (
    select * , px = (select count(1) from tb where tid < t.tid) + 1 from tb t
    ) m,
    (
    select * , px = (select count(1) from tb where tid < t.tid) + 1 from tb t
    ) n
    where n.tid =3 and m.px - n.px=-1 --找到当前ID的前条数据
    order by m.tid
      有了这个排序列 互换排序列(PX)就可以实现了
      

  4.   

    主要是你那个支持拖拉的功能  我感觉html的ui跟li 可以
    先在页面上放一个div<div id="divmenu" runat="server"></div>从数据库读出菜单后 
    在page_load()
    写个方法 循环 this.divmenu.InnerHtml="";
    for(int i=0;i<dt.Rows.Count;i++)
    {
    this.divmenu.InnerHtml+="<ul"+"id=ud"+i+">"
    for(int j=0;j<dt.Columns.Count)
    {
    this.divmenu.InnerHtml+="<li>"+dt.Rows[i][j]+"</li>";
    }
    this.divmenu.InnerHtml+="</ul>";
    }后台写js方法来能让他拖拉function order(tt,old,classover,classout) { 
    var sf = arguments.callee; //get the function self 
    var trs = tt.getElementsByTagName('tr'); 
    for(var i=0;i<trs.length;i++) { 
    trs[i].onmousedown = function () { 
    if(this.style.cursor == 'move') { 
    return false; 

    classout = this.className; 
    this.className = classover; 
    this.style.cursor = 'move'; 
    old = this; 

    trs[i].onmouseover = function () { 
    if(this.style.cursor == 'move' || !old) { 
    return false; 

    var tmp_old = old.cloneNode(true); 
    var tmp_now = this.cloneNode(true); 
    var p = this.parentNode; 
    p.replaceChild(tmp_now,old); 
    p.replaceChild(tmp_old,this); 
    sf(tt,tmp_old,classover,classout); 

    trs[i].onmouseout = function () { 
    //this.className = classout; 

    trs[i].onmouseup = function () { 
    this.className = classout; 
    this.style.cursor = ''; 
    old = null; 


    }
    把以上的JS方法里头的Tr改成UL
    试试看吧
      

  5.   

    额。。也不一定要拉动 我想的就是。。恩你见过gridview点开编辑列后左下角那个框框的功能吧?就是点一下某列 那列变蓝 被选中 然后右面有一个上移下移的按钮 移动改变顺序  就是这种 该怎么去实现啊?我遇到的第一个困难就是怎么让用户点击datalist中的某个item后那个item就背景变蓝被选中  也就是怎么知道用户点的是datalist中的哪一列呢(不是超链接的那种点击)?
      

  6.   

    简单实现:添加一数据列order和inserttime,类型都为datetime。第一次插入时候都设置为当前时间。当上移时候和上面的记录交换order的值(下移反之),置顶时候设置为最新时间,取消置顶时候设置为与inserttime相同的值
      

  7.   

    诶~不错 。。用时间去排序 好主意  有点思路了  O(∩_∩)O谢谢~就是还不知道 怎么选定一列 难道要用radiobutton然后遍历datalist中的radiobutton吗?感觉这样好不人性 啊。。