ITPUB??ì3
ITPUB论坛 » Web开发 » ASP.NET与AJAX » 问题打包问~

新一届的微软MVP评选已经开始,欢迎各位推荐!

标题: 问题打包问~
离线 woodytid



精华贴数 0
个人空间 0
技术积分 230 (8370)
社区积分 0 (1643135)
注册日期 2007-11-28
论坛徽章:1
2008年新春纪念徽章     
      

发表于 2008-5-9 02:26 
问题打包问~

有两个问题请问:

1.select distinct Dcode as 代码,Dname as 名称,Convert(varchar(10),Datetime,120) as 购买日期,Ocost as 净值,Dup as [增长率(%)],mumber as 份额,Ocost*mumber as 市值,Inmoney as [投入金额],Backmy as [赎回金额],Convert (numeric(12, 4), Dmony*mumber) as [当日盈亏], Convert (numeric(12, 4), Dmony*mumber/Inmoney) as [收益率(%)] from fundcost,mfund where Dcode = Codef  and  People = '" + id + "'

在这句sql语句上我想加多一个对select结果的一个排列"order by mumber",请问该怎么加?


2.我有一个dropdownlist
   现在我为它添加数据源用dataset填充:
      string conn = WebConfigurationManager.ConnectionStrings["EndDesignConnectionString"].ConnectionStr  ing;
            SqlConnection cn = new SqlConnection(conn);
            cn.Open();
            string strsql = "select Codef from mfund where People = '" + Session["uid"] + "'";
            SqlDataAdapter myda = new SqlDataAdapter();
            myda.SelectCommand = new SqlCommand(strsql, cn);
            SqlCommandBuilder cmdbuilder = new SqlCommandBuilder(myda);
            DataSet ds = new DataSet();
            myda.Fill(ds, "mfund");
            DropDownList1.DataSource = ds;
            DropDownList1.DataBind();
            //DropDownList1.DataTextField = "Codef";
            myda.Update(ds, "mfund");
            cn.dispose();
            cn.close();

然后我将dropdownlist的datatextfield和datavaluefield都设置为Codef。
显示是没问题,然后我再用SelectedIndexChanged事件编写代码:

         string conn = WebConfigurationManager.ConnectionStrings["EndDesignConnectionString"].ConnectionString;
        SqlConnection cn = new SqlConnection(conn);
        cn.Open();
        string code = DropDownList1.SelectedValue.ToString();
       // int cc = Convert.ToInt32(code);
        SqlCommand cmd = new SqlCommand("select Ocost  from fundcost where Dcode ='" + code + "'", cn);
        double cost = Convert.ToDouble(cmd.ExecuteScalar());
        cmd.Dispose();
        cmd.CommandText = "select Dname from fundcost where Dcode='" + code + "'";
        string name = Convert.ToString(cmd.ExecuteScalar());
        cmd.Dispose();
        Label4.Text = name + "的单位净值是:" + cost;
        cn.Dispose();
        cn.Close();

问题出来了,我运行的时候不管怎么选择dropdownlist里面的item,但是显示的总是第一个item的净值。
例如dropdownlist里面有21300,21311,不管我怎么选都选不了21311的净值。


只看该作者    顶部
 
    

相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问