1:
bool flag = false;
foreach(ListItem item in this.ListBox1.Items)
{
if(item.Text == this.label1.Text)
{
flag = true;
break;
}
} if(flag)
{
s1:
}
else
{
s2;
}

解决方案 »

  1.   

    2:采用动态sql来实现(如果是存储过程)
    如果不是,就循环ListBox的Item,构造sql语句
      

  2.   

    string sValue ="";
    bool bExist = false;
    foreach(ListItem o in this.ListBox1)
    {
    if(o.Selected)
    {
    sValue += "'"+ o.Value +"',";
    }
    if(o.Text.Trim() == this.TextBox1.Text.Trim())
    {
    bExist = true;
    }
    } if(bExist)
    {
    //×?s1
    } if(sValue.Length>0)
    {
    sValue = sValue.Substring(0,sValue.Length-1); string strSQL =" .............  where name in("+ sValue +" )";
    }
      

  3.   

    1、建立一个循环,将listbox中的item和label.text的内容进行比较
    2、建立一个循环,取出其值,生成一个符合sql语法的string
      

  4.   

    1.
    for(int SourceCount = 0; SourceCount < this.LBoxSource.Items.Count; SourceCount++)
    {
    if(this.LBoxSource.Items[SourceCount].Selected == true)
    {
    if(this.LBoxTarget.Items[TargetCount].Text == this.Label1.Text)
    {
    执行s1;
    }
    else
                      {
                               执行s2;
                      }
               }
    }
    2.
    String StrText = "";
    for(int SourceCount = 0; SourceCount < this.LBoxSource.Items.Count; SourceCount++)
    {
    if(this.LBoxSource.Items[SourceCount].Selected == true)
    {
    StrText += this.LBoxSource.Items[SourceCount].Text+",";
              }
    }
    select id from table where xxx in (StrText.TrimEnd(','));
      

  5.   

    String sql = "select * from where";
    foreach(ListItem item in this.ListBox1.Items)
    {
    sql = sql + item + "AND"
    }
    sql = sql.substring(0. sql.length()-3);
      

  6.   

    有没有能提供html格式的呀,以上的这些我实再是转不过来啊:(
      

  7.   

    第一个问题我已经解决了,可第二个问题,麻烦高手,能写成html 格式的吗