你加
if(!IsPostBack)
没有??
GridView和DataGird有一个小小的Bug,假如删除这个列而页面没有更新再删除的话会黄页
还有一个Index的Bug.

解决方案 »

  1.   

    是服务器控件。代码如下,但是我把代码注释了还是不行。
    //if (!IsPostBack)
            //{
            //    TxBpj.Text = "";        //    if (e.CommandName == "Select")
            //    {
            //        int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
            //        string id = Gvshare.Rows[((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex].Cells[0].Text.ToString();        //        SqlDataReader dr;
            //        SqlDataReader psdr;
            //        dr = DB.ReturnWorkDatasetcontent(Convert.ToInt32(id));
            //        psdr = DB.ReturnWorkDatasetpscontent(Convert.ToInt32(id), Session["usernameguid"].ToString());
            //        while (dr.Read())
            //        {
            //            Lbname.Text = dr["username"].ToString();
            //            Lbtime.Text = Convert.ToDateTime(dr["workdate"].ToString()).ToString("yyy-MM-dd");        //            Lbtitle.Text = dr["worktitle"].ToString();
            //            Lbcontent.Text = dr["workcontent"].ToString();
            //            Lbbz.Text = dr["workbz"].ToString();
            //            Label2.Text = dr["workid"].ToString();
            //            Label4.Text = dr["usernameguid"].ToString();        //            LbBool.Text = "未批示";
            //        }
            //        while (psdr.Read())
            //        {
            //            TxBpj.Text = psdr["pscontent"].ToString();
            //            LbBool.Text = psdr["psbool"].ToString();
            //        }        //        LbBool.Visible = true;        //        Lbname.Visible = true;
            //        Lbtime.Visible = true;        //        Lbtitle.Visible = true;
            //        Lbtitle.Visible = true;
            //        Lbcontent.Visible = true;
            //        Lbbz.Visible = true;
            //        Label1.Visible = true;
            //        TxBpj.Visible = true;
            //        Btnpj.Visible = true;
            //    }
            //}
      

  2.   

    如果加了
    if (!IsPostBack) ,无法显示数据 protected void Gvshare_RowCommand(object sender, GridViewCommandEventArgs e)
        {if (!IsPostBack) 
    {        //    TxBpj.Text = "";         //    if (e.CommandName == "Select") 
            //    { 
            //        int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; 
            //        string id = Gvshare.Rows[((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex].Cells[0].Text.ToString();         //        SqlDataReader dr; 
            //        SqlDataReader psdr; 
            //        dr = DB.ReturnWorkDatasetcontent(Convert.ToInt32(id)); 
            //        psdr = DB.ReturnWorkDatasetpscontent(Convert.ToInt32(id), Session["usernameguid"].ToString()); 
            //        while (dr.Read()) 
            //        { 
            //            Lbname.Text = dr["username"].ToString(); 
            //            Lbtime.Text = Convert.ToDateTime(dr["workdate"].ToString()).ToString("yyy-MM-dd");         //            Lbtitle.Text = dr["worktitle"].ToString(); 
            //            Lbcontent.Text = dr["workcontent"].ToString(); 
            //            Lbbz.Text = dr["workbz"].ToString(); 
            //            Label2.Text = dr["workid"].ToString(); 
            //            Label4.Text = dr["usernameguid"].ToString();         //            LbBool.Text = "未批示"; 
            //        } 
            //        while (psdr.Read()) 
            //        { 
            //            TxBpj.Text = psdr["pscontent"].ToString(); 
            //            LbBool.Text = psdr["psbool"].ToString(); 
            //        } 
            //        LbBool.Visible = true;         //        Lbname.Visible = true; 
            //        Lbtime.Visible = true;         //        Lbtitle.Visible = true; 
            //        Lbtitle.Visible = true; 
            //        Lbcontent.Visible = true; 
            //        Lbbz.Visible = true; 
            //        Label1.Visible = true; 
            //        TxBpj.Visible = true; 
            //        Btnpj.Visible = true; 
            //    } 
            //}
      

  3.   

    如果加了if (!IsPostBack)    无法显示数据点击了没有反应。
    代码是加在整个事件中的。试过其他电脑还是不行
     protected void Gvshare_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            
      

  4.   

    换过其他的电脑都是打不开,是不是iss问题