我已經添加了最喜歡的顏色列表的方法存儲在doTableUsers單個用戶:使用在C#ASP淨列表方法
List<string> colorList = new List<string>();
....
if (reader.HasRows)
{
while (reader.Read())
{
idColor = reader["idColor"].ToString();
colorList.Add(idColor.ToString());
}
ns = "";
foreach (string s in colorList)
{
if (ns.Length != 0)
{
ns += ", ";
}
ns += s;
}
}
現在我需要顯示它在GridView中爲自己喜愛的單用戶顏色。
如果寫在代碼隱藏在GridView方法:
Response.Write(str.ToString());
在輸出時,我的顏色正確的列表:
Antique White, Blueviolet, Dark Blue
但在查詢中通過了展會的GridView中的參數是逗號,逗號丟失:
Antique WhiteBluevioletDark Blue
我的代碼如下,提前謝謝。
str = null;
strArr = null;
count = 0;
str = ns == null ? "" : ns.ToString();
char[] splitchar = { ',' };
if (!string.IsNullOrEmpty(str))
{
strArr = str.Split(splitchar);
}
else
{
strArr = null;
}
for (count = 0; count <= strArr.Length - 1; count++)
{
sql = "......";
}
DataSet dsProducts = new DataSet();
using (OdbcConnection cn =
new OdbcConnection(ConfigurationManager.ConnectionStrings["ConnMySQL"].ConnectionString))
{
cn.Open();
using (OdbcCommand cmd = new OdbcCommand(sql, cn))
{
for (count = 0; count <= strArr.Length - 1; count++)
{
cmd.Parameters.AddWithValue("param1", Server.UrlDecode(strArr[count].Trim()));
Response.Write(Server.UrlDecode(strArr[count].Trim()));
}
}
}
@AntonioMailtraq,這是如何解決這個問題在喲你的問題? –
@LarsKristensen我不知道。 – Artiom