protected void  gvQueInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
          if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[2].Text = Convert.ToString(Convert.ToDateTime(e.Row.Cells[2].Text).ToShortDateString());
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ((LinkButton)(e.Row.Cells[4].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')");
        }
}就是这段。不加之前就能全部显示,一加就不行了,只显示一条。大家帮我看看是怎么回事

解决方案 »

  1.   

    代码没看出来什么问题啊,
    if (e.Row.RowType == DataControlRowType.DataRow)
      {
      e.Row.Cells[2].Text = Convert.ToString(Convert.ToDateTime(e.Row.Cells[2].Text).ToShortDateString());
     ((LinkButton)(e.Row.Cells[4].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')");  }
    这样写可以吧。是不是出错了,你把错误信息给处理了?
      

  2.   

    我发现e.Row.Cells[2].这里面的2有问题,能告诉我这是什么意思吗?
      

  3.   

    有些页面的e.Row.Cells【这里的数字不一样的】。不知道为什么
      

  4.   

    代码没有问题,建议写成1楼那样的,至于cells【数字】数字指的是列的索引
      

  5.   

    我知道了。是那个索引跟gridv里面的时间和删除不对应。谢谢你们