DropDownList在读取SelectedValue后发生了变化!!!! [英] DropDownList changed after reading SelectedValue !!!!

查看:129
本文介绍了DropDownList在读取SelectedValue后发生了变化!!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生

i我正在使用asp.net FORMS Vs2010 + MySql

i有一个下拉列表绑定到数据(用户名,密码,用户排名),我显示用户名我按所选值返回密码,按等级排序的下拉列表



下拉列表丢失所选项目的问题,并在读取其selectedValue后选择另一个项目但不是全部它的物品

确实下拉列表工作得很好,所选项目在读取所选值后仍然保持不变,但只有一个COND。这样的用户名有一个唯一的密码



例如:



用户通过

aaa 1234

bbb 1234

ccc 34343

dddd 67657





如果我选择ccc它将返回34343选择索引2

如果我选择dddd它将返回67657选择索引3

如果我选择aaa它将返回1234如果aaa比bbb更高等级

如果我选择bbb它将返回1234选择索引1







dear sir
i am using asp.net FORMS Vs2010 + MySql
i have a dropdownlist binded to a datasoure ( username , password , user rank), i display the username and i return the password in selected value and the dropdownlist sorted by rank

the problem the dropdownlist lose the selected item and select another item after reading its selectedValue but not for all its items
indeed the dropdownlist working so fine and the selected item remains even after reading selected value but IN ONLY ONE COND. that such username has a unique password

for example:

user pass
aaa 1234
bbb 1234
ccc 34343
dddd 67657


if i choose ccc it will return 34343 selected index 2
if i choose dddd it will return 67657 selected index 3
if i choose aaa it will return 1234 if aaa is higher rank than bbb
if i choose bbb it will return 1234 selected index 1



protected void Page_Load(object sender, EventArgs e)
       {
          if (!IsPostBack)
           {

               DataSrc = new SqlDataSource("MySql.Data.MySqlClient", ConnStr, SelCmd);

              this.Controls.Add(DataSrc);

              DropDownList1.DataSource = DataSrc;
               DropDownList1.DataTextField = "UserName";
               DropDownList1.DataValueField = "PassWord";
              DropDownList1.DataBind();
           }

       }







< br $> b $ b



请帮助我

thx很多

bye







please kindly help me
thx alot
bye

推荐答案

如果刷新数据源,则更改所选索引。不要在回发时刷新数据源。
If you refresh the data source, the selected index is changed. Don''t refresh the data source on postback.


这篇关于DropDownList在读取SelectedValue后发生了变化!!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆