【发布时间】:2015-09-28 22:48:22
【问题描述】:
我有一个从 SQL Server 数据库填充数据的 ASP ListView 控件,它按设计工作。我还有一个 ASP Listbox 控件,它使用 ListView 控件中的 ID 和名称填充,它有点工作,也就是说,如果我选择它,它会按设计显示,但如果我继续从 ListView 控件中选择同一行,它不断将它添加到列表框中,这不是我想要的,我宁愿它只显示一次,无论我从列表视图中选择同一行多少次。
这就是我所拥有的
protected void distList_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
{
int rowIndex;
distList.SelectedIndex = e.NewSelectedIndex;
rowIndex = distList.SelectedIndex;
string sapId = distList.DataKeys[rowIndex].Values[0].ToString();
string DistributorName = distList.DataKeys[rowIndex].Values[1].ToString();
string output = sapId + " " + DistributorName;
SAPListBox.Items.Add(output);
}
我一直处于停滞状态,因为我整天都在尝试很多事情却一无所获,我想我可能只是错过了一些东西。
【问题讨论】:
-
与经典 ASP 无关,请重新标记。
标签: c# web-controls