gridview and if statement
本文关键字:statement if and gridview | 更新日期: 2023-09-27 17:50:03
我有一个gridview控件,一个可见的按钮被设置为false。据说当我选择gridview上的某一行时,它会将按钮的可见设置为true。
但是现在的问题是,尽管在后面的代码中设置了if语句,按钮仍然对false可见。下面是后面的代码:protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
Label certify = (Label)GridView1.SelectedRow.FindControl("certify");
Label Status = (Label)GridView1.SelectedRow.FindControl("Status");
if ((certify.ToString() == "True") & (Status.ToString() == "Not Paid"))
{
paymentbtn.Visible = true;
}
}
当我调试程序时,我管理从gridview获取数据。认证设置为True, Status设置为Not Paid。但是,代码仍然跳过if语句。我也不知道为什么……
您需要使用label
的Text
属性而不是调用标签的ToString()来获取值
if ((certify.ToString() == "True") & (Status.ToString() == "Not Paid"))
{
paymentbtn.Visible = true;
}
if ((certify.Text == "True") & (Status.Text == "Not Paid"))
{
paymentbtn.Visible = true;
}