日期:2014-05-20  浏览次数:20418 次

继承自GridView的控件,在OnRowDataBound中加入了一列来显示行序号,但分页行的ColumnSpan在什么时候设置呢?
我在继承自GridView的控件中加入了一列,用来显示序号,问题是列加入后,分页行在显示时会差了一个单元格,那位做过这种空间的可否指点一二?
或说说如何在继承GridView的控件中加入序号列?
我是用一下代码加入的:

///   <summary>
                ///   覆写OnRowDataBound事件,添加序号列
                ///   </summary>
                ///   <param   name= "e "> </param>
                protected   override   void   OnRowDataBound(GridViewRowEventArgs   e)
                {
                        TableCell   tableCell   =   null;
                        if   (e.Row.RowType   ==   DataControlRowType.Header)
                        {
                                tableCell   =   new   TableCell();
                                tableCell.Text   =   "序号 ";
                                e.Row.Cells.AddAt(0,   tableCell);
                        }
                        if   (e.Row.RowType   ==   DataControlRowType.DataRow)
                        {
                                tableCell   =   new   TableCell();
                                int   rowNo   =   this.PageIndex   *   this.PageSize   +   e.Row.RowIndex;
                                if   (this.PageIndex   ==   0)   rowNo++;
                                tableCell.Text   =   rowNo.ToString();
                                e.Row.Cells.AddAt(0,   tableCell);
                        }
                        if   (e.Row.RowType   ==   DataControlRowType.Pager)
                        {
                               
                        }
                        base.OnRowDataBound(e);
                }

------解决方案--------------------
if (e.Row.RowType == DataControlRowType.Pager)