标题:怎么解决:javascript实现asp.net中的两个listbox的项的双击移动时没有更新
只看楼主
ibiws
Rank: 1
来 自:哈尔滨
等 级:新手上路
帖 子:55
专家分:0
注 册:2007-7-12
 问题点数:0 回复次数:0 
怎么解决:javascript实现asp.net中的两个listbox的项的双击移动时没有更新
怪:用javascript移动listbox的项但是更新数据库时lb_Trust_Major.Items.Count没有变化!
我有2个listbox:lb_NotTrust_Major 和 lb_Trust_Major ,我用javascriot实现他们之间的项的移动,但是我在更新发现lb_Trust_Major.Items.Count的值没有变化。大家帮我看看到底时怎样回事吧!谢谢大家~

            string js = "<script language=javascript> function change()";
            js += "{";
            js += "var lb_Trust_Major = document.getElementById('" + lb_Trust_Major.ClientID + "');";
            js += "var lb_NotTrust_Major = document.getElementById('" + lb_NotTrust_Major.ClientID + "');";
            js += "var addOption=document.createElement('option');";
            js += "  var index1; ";
            js += "if(lb_Trust_Major.length==0)return(false);";
            js += "  index1=lb_Trust_Major.selectedIndex;  ";
            js += "  if(index1<0)return(false);";
            js += " addOption.text=lb_Trust_Major.options(index1).text; ";
            js += "addOption.value=lb_Trust_Major.value; ";
            js += "lb_NotTrust_Major.add(addOption); ";
            js += "lb_Trust_Major.remove (index1)";
            js += "}";
            js += "</script>";

            //注册该 javascript ;
            this.RegisterStartupScript("", js);
            //为控件添加双击事件;
            this.lb_Trust_Major.Attributes.Add("onDblClick", "change();");
        
------------------------------------------------------】
    protected void bt_UpdateDB_Click(object sender, EventArgs e)
    {
        string[] strSQLs;//字符串数组,用于保存查询语句
        strSQLs = new string[lb_Trust_Major.Items.Count + 1];
        strSQLs[0] = "delete from app_rel_FriendMajor where MasterMajorCode = '" + ddl_Main_Major.SelectedValue.ToString() + "'";
        for (int i = 1; i < lb_Trust_Major.Items.Count + 1; i++)
        {
            strSQLs[i] = "insert into  app_rel_FriendMajor (MasterMajorCode, TrustMajorCode) " +
                        " values (  '" + ddl_Main_Major.SelectedValue.ToString() + "', '" + lb_Trust_Major.Items[i - 1].Value.ToString() + "') ";

        }
        int n = Database.ExecuteSqls(strSQLs);
        
       Response.Write("<Script>alert('修改成功!');</Script>");//11.12

        

    }

调试发现lb_Trust_Major.Items.Count 的值没有变化,那么我的移动就是没有作用。不知道是什么原因,高手帮我看看吧!小弟感激不尽!
搜索更多相关主题的帖子: listbox javascript asp 
2007-12-15 22:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-192692-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.168200 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved