刘政道 - 应用程序框架

《31天学会CRM项目开发(C#编程入门及项目实战)》作者,IT经理,程序员
  博客园  :: 新随笔  :: 联系 :: 管理

Asp.Net GridView 的e.Row.Cells[0].Text为什么取不到值?

Posted on 2008-08-22 11:38  刘政道  阅读(4920)  评论(0编辑  收藏  举报
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
       
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton bt = new LinkButton();
            bt = (LinkButton)e.Row.Cells[0].FindControl("LinkButton_GuoZhang");
            bt.CommandArgument = e.Row.Cells[0].Text;
            bt.Enabled = false;
            if (e.Row.Cells[11].Text == "0")
                bt.Enabled = true;
            bt = (LinkButton)e.Row.Cells[0].FindControl("LinkButton_HuiChong");
            bt.CommandArgument = e.Row.Cells[0].Text;
            bt.Enabled = false;
            if (e.Row.Cells[11].Text == "1")
                bt.Enabled = true;
            bt = (LinkButton)e.Row.Cells[0].FindControl("LinkButton_Del");
            bt.CommandArgument = e.Row.Cells[0].Text;
            bt.Enabled = false;
            if (e.Row.Cells[11].Text == "0")
            {
                bt.Enabled = true;
                bt.Attributes.Add("onclick", "javascript:if(confirm('您确定要删除吗?')==false) return false;");
            }
        }

    }

 

 

 原因是你将Gridview1的各字段转化成了模板