动态下拉列表框 [英] Dynamic Dropdown list box

查看:79
本文介绍了动态下拉列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个动态下拉列表,并向其中添加了一些数据.这是在ascx.cs页中完成的,完整的代码已在pageload事件中编写.

当我们在asp.net,c#中选择下拉列表时.我一直在重新加载页面并跳过值.例如:我有一个下拉列表,其值如下:
下拉列表-ID(-选择-,1,2,3,4,5,6,7,8,9)

当选择标识索引Changed事件将被解雇,并且下拉值我会送进去.然后,我想在会话中捕获该值.

但是,当我选择一个ID时,-Select-值就会加载到下拉菜单中以显示.

实际的想法是,当我根据选择选择值3或6或任何其他值时,需要显示数据.

预先感谢.

I had created a dynamic dropdown list and got some data into it. this is been done in ascx.cs page and the complete code is been written in pageload event.

When we select the Dropdown list in asp.net,c#. I have been reloading the page and skipping the values. For example: I have a dropdown that have the values:
dropdown - Id''s (-- Select --,1,2,3,4,5,6,7,8,9)

When Id is selected the Index Changed event would be fired and the dropdown value I would be sending into it. Then I want to capture that value in an session.

But when I select an Id then the -- Select -- value is been loaded into the dropdown to appear.

The actual think is when I select the value 3 or 6 or anyother based on the selection the data need to be appeared.

Thanks in advance.

推荐答案



您是否将下拉列表绑定到每个页面加载中,而不考虑回发了什么?
如果是这样,则仅在第一页加载中绑定下拉菜单.

Hi,

Are you binding your dropdown list in the each pageload irrespective of the post back?
If so, bind your dropdown only in the first page load.

if (!IsPostBack)
{
//then bind your dropdown.
}



希望这会有所帮助.



Hope this helps.


这篇关于动态下拉列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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