当两个具有相同值的项目时,如何从下拉列表中获取所选项目 [英] how to get selected item from drop down list when two items having same value

查看:67
本文介绍了当两个具有相同值的项目时,如何从下拉列表中获取所选项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正从具有roomno的数据库中获取下拉列表绑定。作为textfield和guestid的值如:

roomno = 102,GuestID = 2;

romno = 103,guestid = 2;

roomno = 104,guestid = 1;



当我们将这些数据绑定到下拉列表并选择roomno:103时,它将始终选择具有相同值的第一个索引上的项目(如roomno 102和103都有相同的猜测,即2)



我如何选择具有相同值的下一个索引上的项目;

plz recommended我的任何解决方案....

i use!(回帖)在页面加载但它不起作用。



thanx提前!!! :)

i am having a drop down list bind from database having roomno. as textfield and guestid as value like :
roomno=102, GuestID=2;
romno=103, guestid=2;
roomno=104, guestid=1;

when we bind this data to drop down list and select roomno: 103 it will always select the item on first index with same value (as roomno 102 and 103 both having same guestid i.e. 2)

how do i select the item on next index having same value;
plz suggest me any solution for ds....
i use !(is post back) on pageload but it doesnt work for this.

thanx in advance!!! :)

推荐答案

大家好,请尝试这个,如果多个项目有保存值,您可以轻松获得所选项目的索引。

Hello you please try this and you can get easily index of selected item if more than one items have save values.
ddlRoomNo.SelectedIndex = ddlRoomNo.Items.IndexOf(ddlRoomNo.Items.FindByText("103"));


这篇关于当两个具有相同值的项目时,如何从下拉列表中获取所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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