在列表框中选择索引已更改问题 [英] on listbox selected index changed problem

查看:57
本文介绍了在列表框中选择索引已更改问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我将listbox1绑定为60px高度。当我使用垂直滚动条选择低于60px高度的项目(用于提升另一个列表框2,使用所选项目)时,列表框的状态将返回到第一个位置,从而所选项目对于用户来说是未知的。是否有任何设施可以保留所选项目本身的列表框状态。

问候。





In my project I bind a listbox1 with say 60px height. When I select an item (for raising another listbox2, using the selected item) that is beneath the 60px height using vertical scroll bar, the status of the listbox is returning back to the first position thereby the selected item goes unknown for the user. Is there any facility to retain the status of listbox on that selected item itself.
Regards.


protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) 
{ 
	if (ListBox1.SelectedIndex == 0) 
	{ 
	
	} 
	else 
	{ 
		SqlDataAdapter da1 = new SqlDataAdapter("select block_name,block_code from block where dist_code='" + v_dist_code + "'", con); 
		SqlCommandBuilder cb1 = new SqlCommandBuilder(da1); 
		DataSet ds1 = new DataSet("block"); 
		da1.Fill(ds1, "block"); 
		for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) 
		{ 
			List adds1 = new List(); 
			adds1.Add(ds1.Tables[0].Rows[i].ItemArray[0].ToString()); 
			string name1 = ds1.Tables[0].Rows[i]["block_name"].ToString(); 
			if (name1 == ListBox1.SelectedValue) 
			{ 
				v_block_code = Convert.ToInt32(ds1.Tables[0].Rows[i]["block_code"].ToString()); 
			}
				
		} 
	}
	
// once an item is selected the position of listbox goes to top and things happens as reported.





David_Wimbley:移动代码从评论到问题[/编辑]



//这个问题只适用于VS2008 R2而不适用于VS2008!



David_Wimbley: Moved code from comment to question[/EDIT]

// This problem only with VS2008 R2 and not with VS2008!

推荐答案

请试试这个..

Please try this..
<script src="jquery-1.4.2.js" type="text/javascript"></script>
    <script type="text/javascript">


(文件).ready(function(){
(document).ready(function() {


('#btnRight')。click(function(e){
var selectedOpts =
('#btnRight').click(function(e) { var selectedOpts =


这篇关于在列表框中选择索引已更改问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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