日期:2014-05-18  浏览次数:20430 次

暴急,5分钟在线等,问题解决就结帖~~~~~~~~~~~~~~~~~~~~~~~~~~~
//广告指向页面的地址(下载页,注册页)
SqlConnection   conn2   =   new   SqlConnection(strCon);
SqlCommand   cmd2   =   new   SqlCommand( "select   ID,Url,Chinese   from   AD_Url ",   conn2);
conn2.Open();
SqlDataReader   reader2   =   cmd2.ExecuteReader();
while   (reader2.Read())
{
        ListItem   oItem   =   new   ListItem();
        oItem.Text   =   reader2[ "Chinese "].ToString();
        oItem.Value   =   reader2[ "ID "].ToString();
        this.DropDownList5.Items.Add(oItem);
}  
cmd2.Dispose();
conn2.Close();

if   (this.DropDownList5.SelectedValue   !=   null)
{
          SqlConnection   conn1   =   new   SqlConnection(strCon);
          SqlCommand   cmd1   =   new   SqlCommand( "select   ID   from   AD_Append ",   conn1);
          conn1.Open();
          SqlDataReader   reader   =   cmd1.ExecuteReader();
          while   (reader.Read())
          {
                  this.TextBox2.Text   =   this.DropDownList5.Text   +   "?id= "   +   reader[ "id "].ToString();
          }

            cmd1.Dispose();
            conn1.Close();
}

以前做出来后,直接加在IF里边的语句就生成一个链接地址了,现在老板说DropDownList5里边要显示中文,我也显示了,只是生成链接时有是中文加ID号了,还要改成英文的,怎么做啊,急

------解决方案--------------------

------解决方案--------------------
谁叫你把链接地址存在.Text里的,你不会放在.value之类的属性里吗?
------解决方案--------------------
oItem.Value = reader2[ "ID "].ToString();
为什么一定要存ID号?
oItem.Value=String.Format( "{0}?id={1} ",reader2[ "English "],reader2[ "ID "])
------解决方案--------------------
SqlConnection conn2 = new SqlConnection(strCon);
SqlCommand cmd2 = new SqlCommand( "select ID,Url,Chinese from AD_Url ", conn2);
conn2.Open();
SqlDataReader reader2 = cmd2.ExecuteReader();
while (reader2.Read())
{
ListItem oItem = new ListItem();
oItem.Text = reader2[ "Chinese "].ToString();
oItem.Value = reader2[ "Url "].ToString() + "?id= " + reader2[ "ID "].ToString();
this.DropDownList5.Items.Add(oItem);
}
cmd2.Dispose();
conn2.Close();

if (this.DropDownList5.SelectedValue != null)
{
this.TextBox2.Text = this.DropDownList5.Value.ToString();
}

不知道你是不是这个意思