如何在asp.net中创建动态下拉列表? [英] How to create dynamic drop down list in asp.net?

查看:69
本文介绍了如何在asp.net中创建动态下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试开发一个网页,在该网页上可以基于少数条件创建动态下拉列表.

在数据库端,具有三列的表

列名称
===========
ID
名称
ParentID

其中ID是唯一的序列号,Name是类别名称,ParentID是它指向的类别ID.

例如,"a"是父代0和id为1的类别,"b"是父代1为且id为2的另一个类别,同样,"c"是父代2为2的另一个类别它的ID是3,依此类推.

在ASP.Net设计端,

一个下拉控件和一个文本框,其中下拉列表包含父级名称值对(ID,名称).如果未选择下拉菜单,并且在下面的文本框中输入了名称,则会将其创建为类别,其父级标识为0(零).每当一个下拉选择与类别名称并输入名称从下拉列表中选择保存,它被保存为的parentid为类ID的子类别.

如果下拉列表中选择的类别包含其他类别,则此处将显示动态下拉列表,其中将填充在第一个下拉列表中选择的适当类别.如果第二个下拉列表类别还有其他类别,则将填充一个新的动态下拉列表,并用适当的类别填充.而且这种情况一直持续下去...

所以,请在这方面帮助我.

问候,
Rajendra Prasad

Hi,
i''m trying to develop a web page where dynamic drop down lists can be created based on few conditions.

At Database Side, a table with three columns

Column Name
===========
ID
Name
ParentID

where ID is unique sequence number, Name is the category name & ParentID is the category id to which it points to.

for example, ''a'' is a category with parentid 0 & id as 1, ''b'' is another category whose parentid is 1 & id as 2, and again ''c'' is another category whose parentid is 2 and its id is 3, etc..

At ASP.Net Design side,

a drop down control and a textbox where drop down contains the parentid name value pairs (ID, Name). when drop down is not selected & a name is entered in the below textbox, it is created as a category with parentid as 0 (zero). whenever a drop down is selected with category name and name is entered as saved, it is saved as a sub category with parentid as category id as selected from the drop down list.

in case if the category selected in the drop down list contains further categories then here, dynamic drop down list to be display as filled with the appropriate categories as selected in the first drop down lists. in case, if the second drop down list category has further categories, then a new dynamic drop down list to be populated and filled with the appropriate categories. and this goes on & on & on ...

So, please help me in this regard.

Regards,
Rajendra Prasad

推荐答案

本文可帮助您创建动态下拉列表.
创建动态下拉列表 [
This article helps you in creating dynamic dropdownlist.
creating dynamic drop down lists[^]


希望 [
Hope this[^]also might help you.


这篇关于如何在asp.net中创建动态下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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