protected void GridView1_RowCommand (object sender, GridViewCommandEventArgs e)
    {
        SqlConnection mycon = can.SqlCon ();
        mycon.Open ();
        int index = Convert.ToInt32 (e.CommandArgument);
        GridViewRow selectedrow = GridView1.Rows[index];
        TableCell id = selectedrow.Cells[0];
        TableCell zjname = selectedrow.Cells[2];
        TableCell zt = selectedrow.Cells[6];        if (e.CommandName == "jinyong")
        {
            if (zt.Text=="禁用") // 为何这句不生效啊,命名 那个TABLEcell的文本是“禁用啊” 
            {
                Page.RegisterStartupScript ("ServiceManHistoryButtonClick", "<script>alert('已经禁用了!')</script>");
            }
            else
            {
               
                
                Page.RegisterStartupScript ("ServiceManHistoryButtonClick", "<script>alert('已经禁用,相关房源以及推荐信息都已经禁用!')</script>");
               
            }
        }
        if (e.CommandName == "huifu")
        {
            if (zt.Text.Equals("正常"))
            {
               。
                 Page.RegisterStartupScript ("ServiceManHistoryButtonClick", "<script>alert('已经正常,相关房源以及推荐信息都已经正常!')</script>");
            }
        }    }
    我的问题是:  if (zt.Text=="禁用") // 为何这句不生效啊,命名 那个TABLEcell的文本是“禁用啊” 

解决方案 »

  1.   

    1、zt 里面有没有控件?2、把zt.Text的内容 输出出来看看到底是什么内容,可以用断点调试的方式,也可以Response.Write(zt.Text);
      

  2.   

    我用response.write("<script lanuage=javsascript>alter('"+zj.text+"')");输出来着,ZT.text 就是“禁用” ,但是为什么总是执行 不相同的分支那?zt 里面没有控件 ,这个不是模板字段 。