Dav*_*ohn 4 c# asp.net listbox
如何检查列表框中是否已存在某个项目?
我正在使用VS 2008 ASP.NET 3.5框架C#.我用了以下代码......
if (ListBox1.Items.Contains(drp_branch.SelectedItem.Value + "-" + txt_acc_no.Text))
{...}
Run Code Online (Sandbox Code Playgroud)
Nae*_*raz 10
试试这个...
string toMatch = drp_branch.SelectedItem.Value + "-" + txt_acc_no.Text;
ListItem item = ListBox1.Items.FindByText(toMatch);
if (item != null)
{
//found
}
else
{
//not found
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16488 次 |
最近记录: |