我正在使用带有下拉菜单的自适应卡,我能够通过使用linq to sql将这些值动态获取到第一个下拉菜单中。现在基于我选择的第一个下拉菜单值,我希望填充第二个下拉列表值。我试过在数据库中有2个表,试图在两个表上执行联接操作以获得第二个下拉值,但是它没有用。
var selectitem = (from each in db.maintabports select new { each.portname }).ToList();
List<AdaptiveCards.Choice> list = new List<AdaptiveCards.Choice>();
List<AdaptiveCards.Choice> list2 = new List<AdaptiveCards.Choice>();
foreach (var item in selectitem)
{
AdaptiveCards.Choice choice = new AdaptiveCards.Choice()
{
Title = item.portname,
Value = item.portname
};
list.Add(choice);
}
var selectitem1 = (from each in db.maintabports join t in db.projmen on each.Id equals t.Id select new { t.projmanager });
foreach (var item1 in selectitem1)
{
AdaptiveCards.Choice choice = new AdaptiveCards.Choice()
{
Title=item1.projmanager,
Value = item1.projmanager
};
list2.Add(choice);
}
var card = new AdaptiveCard()
{
Body = new List<CardElement>()
{
new TextBlock()
{
Color = TextColor.Attention,
Weight = TextWeight.Bolder,
Size = TextSize.Medium,
Text = "Select a title",
},
new ChoiceSet()
{
Id = "title",
Style = ChoiceInputStyle.Compact,
IsRequired = false,
IsMultiSelect = false,
Value = "1",
Choices =list
},
new ChoiceSet()
{
Id = "managernames",
Style = ChoiceInputStyle.Compact,
IsRequired = false,
IsMultiSelect = false,
Value = "1",
Choices =list2
},
},
};