| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 841 人关注过本帖
标题:怪:用javascript移动listbox的项但是更新数据库时lb_Trust_Major.Items.Co ...
取消只看楼主 加入收藏
ibiws
Rank: 1
来 自:哈尔滨
等 级:新手上路
帖 子:55
专家分:0
注 册:2007-7-12
收藏
 问题点数:0 回复次数:0 
怪:用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 的值没有变化,那么我的移动就是没有作用。不知道是什么原因,高手帮我看看吧!小弟感激不尽!
搜索更多相关主题的帖子: Major Trust Count 数据库 Items 
2007-12-12 16:41
快速回复:怪:用javascript移动listbox的项但是更新数据库时lb_Trust_Major.Ite ...
数据加载中...
 
   



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

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