当前位置:编程学习 > C#/ASP.NET >>

问题说起来很杂乱,举例子吧

sql数据库里有一个表tb_store,里面有name(char),storeid,storecompany,price(int),grade。
dropdownlist已经绑定name,想选中dropdownlist中一个值时,另一个textbox中根据price>100或<=100显示对应price值+5或price+6。 --------------------编程问答-------------------- 设置dorp的DataValueField为price,这样就可以直接取DropDownList1.SelectedValue的值了,然后判断并+5或+6 --------------------编程问答-------------------- http://stackoverflow.com/questions/2044067/how-to-convert-enum-to-a-bool-for-databinding-in-winforms --------------------编程问答-------------------- 怎么将DropDownList1.SelectedValue中的值赋给一个变量?能把完整的代码给出来吗? --------------------编程问答-------------------- DropDownList1 设置 DataValueField 为 price ,注册事件 SelectedIndexChanged ,事件方法里取得 DropDownList1.SelectedValue ,判断然后修改 textbox 内容。 --------------------编程问答-------------------- 过程是这样,可是我实现时textbox里的值总是不变,已经在设计版面设置了autopostback,求过程代码。
--------------------编程问答-------------------- ....原来是web的啊。。。用ajax吧 --------------------编程问答-------------------- 帮忙看看我代码哪里错了,感激不尽。
         SqlDataAdapter zxc = new SqlDataAdapter("select * from tb_store order by id desc", strcon);
            DataSet dz = new DataSet();
            sdac.Fill(dz, "tb_store");
            this.dropdownlist.DataSource = dz.Tables["tb_store"];
            this.dropdownlist.DataValueField = "price";
            this.dropdownlist.DataTextField = "name";
            this.dropdownlist.DataBind();
            this.TextBox1.Text = this.ClientId.SelectedValue;
先写到这样,可textbox值不随dropdownlist变化 --------------------编程问答-------------------- SqlDataAdapter zxc = new SqlDataAdapter("select * from tb_store order by id desc", strcon);
  DataSet dz = new DataSet();
  zxc.Fill(dz, "tb_store");
  this.dropdownlist.DataSource = dz.Tables["tb_store"];
  this.dropdownlist.DataValueField = "price";
  this.dropdownlist.DataTextField = "name";
  this.dropdownlist.DataBind();
  this.TextBox1.Text = this.ClientId.SelectedValue;
--------------------编程问答--------------------
引用 7 楼  的回复:
帮忙看看我代码哪里错了,感激不尽。
         SqlDataAdapter zxc = new SqlDataAdapter("select * from tb_store order by id desc", strcon);
            DataSet dz = new DataSet();
            sdac.Fill(dz, "tb_store")……

在dropdownlist的SelectedIndexChanged事件对TextBox赋值
参考http://blog.csdn.net/hongkaihua1987/article/details/6917587 --------------------编程问答-------------------- event怎么加的?
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,