如何在dotnet的网格视图中插入空行 [英] How to insert empty row into the grid view in dotnet

查看:83
本文介绍了如何在dotnet的网格视图中插入空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在gridview中显示空行,这也基于网格视图的页面大小.如果页面大小= 20表示网格仅包含15个记录,则表示我想在gridview中显示5个空行(或)页面大小= 10,那么我有15个记录表示,则我想在第2页的第二个页面中插入5个空行.网格.这是我的要求.....
我认为您知道了,否则请告诉我

解决方案

http://weblogs.asp.net/rajneesh-verma/archive/2010/12/07/add-n-number-of-blank-rows-in-gridview-without-databse.aspx [ http://forums.asp.net/t/1217361.aspx/1 [ ^ ]


http://forums.asp.net/t/1433287.aspx/1 [ 受保护的 无效 FillBlankRowToGrid() { // 此处,您的代码将数据库记录填充到数据表中..... // 如果它将返回15条记录,则此循环将为网格填充5条黑色行 DataRow dr; for ( int i = dt.Rows.Count; i < 20 ; i ++) { dr = dt.NewRow(); dr [ 0 ] = dr [ 1 ] = dr [ 2 ] = dr [ 3 ] = dr [ 4 ] = "; dt.Rows.Add(dr); } dt.AcceptChanges(); grdView.DataSource = dt; grdView.DataBind(); }


i want to show empty rows in the gridview, That also based on the page size of the grid view. If page size=20 means and grid contain only 15 records means then i want to show 5 empty rows in the gridview (or) page size=10 then i have 15 records means then i want to insert 5 empty rows in the 2nd page of the grid. This is my requirment.....
I think u got, If not please let me know

http://weblogs.asp.net/rajneesh-verma/archive/2010/12/07/add-n-number-of-blank-rows-in-gridview-without-databse.aspx[^]
http://forums.asp.net/t/1217361.aspx/1[^]


http://forums.asp.net/t/1433287.aspx/1[^]


For adding blank row in your grid view you need to add that row to your data source before you attach your data source to your grid...

like this...

if you use data set or data table as your data source then after fetching data from your data base then fill your data table or data set..
then check for the record count from your data table or data set..

now if it will return 15 record counted then fire one loop and add new row to that table...

protected void FillBlankRowToGrid()
{  
    //here your code to fill your data table with data base records.....
    //if it will return 15 records then this loop will fill 5 black row to your grid
    DataRow dr;
    for (int i = dt.Rows.Count; i < 20; i++)
    {
        dr = dt.NewRow();
        dr[0] = dr[1] = dr[2] = dr[3] = dr[4] = "";
        dt.Rows.Add(dr);
    }
    dt.AcceptChanges();
    grdView.DataSource = dt;
    grdView.DataBind();
}


这篇关于如何在dotnet的网格视图中插入空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆