C#话语
C#语句
protected void Button3_Click(object sender, EventArgs e)
{
string Text = "(";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cbx = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("cbxId");
if (cbx.Checked == true)
{
Text = Text + "'" + GridView1.DataKeys[i].Value.ToString() + "'" + ",";
}
}
if (Text != "(")
{
Text = Text.Substring(0, Text.Length - 1) + ")";
Session["Number"] = Text;
Response.Redirect("../编辑/change.aspx");
return;
}
else
{
RegisterStartupScript("", "<script>alert('请勾选要调整的设备!')</script>");
return;
}
}
请问上面的语句在 if (Text != "(")这里问题到底出在哪里,为什么在这种情况下
我没有勾选任何信息,点击调整按钮应该是弹出对话框'请勾选要调整的设备!',而系统却总是实现了页面跳转
------解决思路----------------------
设置断点单步调试一下看看Text究竟是什么值。另外比较内容是否相同,可以用Equals方法。
------解决思路----------------------
Response.Redirect("../编辑/change.aspx");
你这不是重定向吗
protected void Button3_Click(object sender, EventArgs e)
{
string Text = "(";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cbx = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("cbxId");
if (cbx.Checked == true)
{
Text = Text + "'" + GridView1.DataKeys[i].Value.ToString() + "'" + ",";
}
}
if (Text != "(")
{
Text = Text.Substring(0, Text.Length - 1) + ")";
Session["Number"] = Text;
Response.Redirect("../编辑/change.aspx");
return;
}
else
{
RegisterStartupScript("", "<script>alert('请勾选要调整的设备!')</script>");
return;
}
}
请问上面的语句在 if (Text != "(")这里问题到底出在哪里,为什么在这种情况下
我没有勾选任何信息,点击调整按钮应该是弹出对话框'请勾选要调整的设备!',而系统却总是实现了页面跳转
------解决思路----------------------
设置断点单步调试一下看看Text究竟是什么值。另外比较内容是否相同,可以用Equals方法。
------解决思路----------------------
Response.Redirect("../编辑/change.aspx");
你这不是重定向吗