如何在不同的DropDownLists之间建立关系 [英] How to Make Relation Between different DropDownLists

查看:73
本文介绍了如何在不同的DropDownLists之间建立关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个包含4列的表,我将这些列绑定到不同的DropdownLists。我需要得到它,如果我改变任何下拉列表值,剩下的dropdwonlist应该影响那个受尊重的行。

我有桌子像这样,



Hi,
I have a table with 4 columns, and i am binding these columns to different DropdownLists. I need to get that, if i change any dropdownlist value, the remaining dropdwonlist should effect with that respected row.
I have table Like this,

id	Name	FatherName	MotherName
1	Name1	Father1 	Mother1
2	Name2	Father2 	Mother2
3	Name3	Father3 	Mother3
4	Name4	Father4 	Mother4







DropDownList1与第一列(id)绑定,

DropDownList1与第二列绑定(姓名),

..

..依此类推..



如果我选择id为1,Dropdownlist2应自动选择Name1,DropDownList3应为Father1 ......依此类推..



如果我更改dropdownlist2值,与上面剩余的下拉列表相同应该有效..



如何使用Apc.net(C#)获得它..



请帮助..




DropDownList1 is Bind with first Column (id),
DropDownList1 is Bind with second Column (Name),
..
..and so on..

If i select id as 1, the Dropdownlist2 should auto select to Name1, and DropDownList3 is to Father1...and so on..

if i change dropdownlist2 value, same as above remaining dropdownlists should effect..

How can i get it by using Apc.net(C#)..

Please help..

推荐答案

逻辑

Logic


  1. 使用OnSelectedIndexChanged方法 [ ^ ] DropDownList
  2. 获取选定值
  3. 循环遍历 DataTable 并找到它所在的行具有选定值(id)
  4. 获取所需的列值( DropDown 值,需要选择)在该行中。
  5. 按照我们在上一步中获得的值选择所有其他 DropDown

  1. Use OnSelectedIndexChanged Method[^] of DropDownList.
  2. Get the Selected Value.
  3. Loop through the DataTable and find the Row where it has that Selected Value (id).
  4. Get required column values (the DropDown values, which need to be selected) in that Row.
  5. Select all other DropDown by the values we got in previous step.


这篇关于如何在不同的DropDownLists之间建立关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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