string strCon = ConfigurationManager.ConnectionStrings["conCTSystem"].ConnectionString;
SqlConnection conSchedule = new SqlConnection(strCon);
conSchedule.Open();
SqlCommand cmdSchedule = new SqlCommand("Select Day From Schedule Where RoomNumber=@roomNumber", conSchedule);
cmdSchedule.Parameters.AddWithValue("@roomNumber", ddlRoomNumber.SelectedValue); //MatchWithDropDownList
using (SqlDataAdapter da = new SqlDataAdapter(cmdSchedule))
{
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables.Count > 0)
{
string ReturnDay = ds.Tables[0].Rows[0]["Day"].ToString();
if (ReturnDay == "Monday")
{
Label1.Text = "abc";
}
else
{
Label1.Text = "cde";
}
}
}
任何人都可以帮我解决这个问题吗?我是使用asp.net c#的新学习者,我面临的问题是当ReturnDay
等于Monday
并且应该显示“abc”结果但输出显示给我的是“cde” ”
答案 0 :(得分:1)
试试这个:
if (ReturnDay.Trim().Equals("Monday"))
{
Label1.Text = "abc";
}
或
if (ReturnDay.Trim().Equals("Monday",StringComparison.InvariantCultureIgnoreCase))
{
Label1.Text = "abc";
}