如何在datagridview中分隔具有不同值的记录并在它们之间添加空行? [英] How to separate records with different values in datagridview and add empty row between them?

查看:66
本文介绍了如何在datagridview中分隔具有不同值的记录并在它们之间添加空行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好日子..

有没有办法在asp.net-vb中做到这一点?我在不同类别的datagridview中有记录。有没有办法添加一个空白行来重新分类那些有2或3个类别的记录?我试图避免创建相同元素但只有不同查询的多个网格视图..谢谢很多。

good day everyone..
is there a way to do this in asp.net-vb? I have records in datagridview of different categories..is there a way around to add a blank row to saparate those records with 2 or 3 categories?Im trying to avoid to create a multiple gridviews of the same elements but only different queries.. thanks a lot.

推荐答案

嗨亲爱的,



尝试这个但是你实现了自己的逻辑



Hi Dear,

try this but you implement your own logic

DataTable dt = new DataTable();
           dt.Columns.Add(new DataColumn("Id"));
           dt.Columns.Add(new DataColumn("Name"));
           for (int i = 0; i < 5; i++)
           {
               DataRow dr = dt.NewRow();
               if (i % 2 == 0)
               {
                   dr["Id"] = "1";
                   dr["Name"] = "Country" + i.ToString();
               }
               else
               {
                   dr["Id"] = "";
                   dr["Name"] = "";
               }
               dt.Rows.Add(dr);
           }
           this.grd.DataSource = dt;
           this.grd.DataBind();


这篇关于如何在datagridview中分隔具有不同值的记录并在它们之间添加空行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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