我有四个下拉列表,在选择asp.net页面文本框字段中的每个下拉列表后应该填写值,在下拉列表页面中选择哪个用户,这里没有SQL业务, 对于前者, ddl1包含...虎狮鹿 ddl2包含...西伯利亚RSA纳米比亚 ddl3包含... Carnivore Carnivore Herbivore
如果用户从ddl1选择tiger,从ddl2选择siberia,从ddl3选择cornivore,则textbox字段应更新为, 老虎西伯利亚食肉动物 我已经使用了StringBuilder和下面的附加类,
public List<StringBuilder> GetAnimalDetails()
{
StringBuilder typo = new StringBuilder();
typo.Append(DropDownListBranch.SelectedValue);
typo.Append(" ");
typo.Append(DropDownListMilestone.SelectedValue);
typo.Append(" ");
typo.Append(DropDownListType.SelectedValue);
typo.Append(" - ");
typo.Append(DropDownListVersion.SelectedValue);
return typo.ToString().ToList();
}
答案 0 :(得分:0)
考虑到简单的文本框填充下拉值,您可以尝试类似
的内容 public string GetAnimalDetails()
{
string typo = string.Empty;
typo = DropDownListBranch.SelectedValue;
if (!string.IsNullOrEmpty(typo) && !string.IsNullOrEmpty(DropDownListMilestone.SelectedValue))
{
typo += " ";
}
typo = typo + DropDownListMilestone.SelectedValue;
if (!string.IsNullOrEmpty(typo) && !string.IsNullOrEmpty(DropDownListType.SelectedValue))
{
typo += " ";
}
typo = typo + DropDownListType.SelectedValue;
if (!string.IsNullOrEmpty(typo) && !string.IsNullOrEmpty(DropDownListVersion.SelectedValue))
{
typo += " - ";
}
typo += DropDownListVersion.SelectedValue;
return typo;
}
protected void DropDownListBranch_SelectedIndexChanged(object sender, EventArgs e)
{
txtAnimalDetails.Text = GetAnimalDetails();
}
protected void DropDownListMilestone_SelectedIndexChanged(object sender, EventArgs e)
{
txtAnimalDetails.Text = GetAnimalDetails();
}
protected void DropDownListType_SelectedIndexChanged(object sender, EventArgs e)
{
txtAnimalDetails.Text = GetAnimalDetails();
}
protected void DropDownListVersion_SelectedIndexChanged(object sender, EventArgs e)
{
txtAnimalDetails.Text = GetAnimalDetails();
}
希望这会有所帮助......