如何在不同的DropDownLists之间建立关系 [英] How to Make Relation Between different 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
- 使用OnSelectedIndexChanged方法 [ ^ ]
DropDownList
。 - 获取选定值。
- 循环遍历
DataTable
并找到它所在的行具有选定值(id)。 - 获取所需的列值(
DropDown
值,需要选择)在该行中。 - 按照我们在上一步中获得的值选择所有其他
DropDown
。
- Use OnSelectedIndexChanged Method[^] of
DropDownList
. - Get the Selected Value.
- Loop through the
DataTable
and find the Row where it has that Selected Value (id). - Get required column values (the
DropDown
values, which need to be selected) in that Row. - Select all other
DropDown
by the values we got in previous step.
这篇关于如何在不同的DropDownLists之间建立关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!