如何在Gridview中显示数据行到Cloumns [英] how to show data rows to cloumns in Gridview

查看:89
本文介绍了如何在Gridview中显示数据行到Cloumns的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



让我解释一下有关数据库的信息.

我有一个表名叫companydetails.

有两个名为COmpanyID,DepartID的文件名.

COmpanyID,DEpartID.
1 ................... 1.1
1 ................... 1.2
1 ................... 1.3
1 ................... 1.4
2 .......... ........ 2.1
2 ................... 2.2
2 ................ 2.3
2 .................. 2.4


这是我的数据出现在数据库表中.


现在我的问题是我必须在网格视图中以如下两行的形式显示此数据.

COmpanyID,dept1,dept2,dept3,dept4

.... 1 ........... 1.1 ..... 1.2 .... 1.3 ..... 1.4
.... 2 ........... 2.1 ..... 2.1 .... 2.3 ..... 2.4




请告诉我如何在c#中执行此操作.

Hi,

let me explain some about database.

i have one table name called companydetails.

there are two fileds name called COmpanyID, DepartID.

COmpanyID , DEpartID.
1...................1.1
1...................1.2
1...................1.3
1...................1.4
2.......... ........2.1
2...................2.2
2.............. ....2.3
2 ..................2.4


This is my data appear in data base table.


Now my question is now i have to show this data in gridview in a 2 rows like this below.

COmpanyID,dept1,dept2,dept3,dept4

....1...........1.1.....1.2....1.3.....1.4
....2...........2.1.....2.1....2.3.....2.4




Please can you tell me how can i do this in c#.

推荐答案

您好,


您可以通过许多逻辑来做到这一点.但给出一种逻辑.

做一件事.当您将表从数据库获取到代码时.循环到该表上,然后根据需要再次创建新的数据tata.
Hi,


you can do it by many logic. But give one logic.

Doing one thing. when you get table from database to your code. Loop on that table and again create new datatabel with your requirement.


这篇关于如何在Gridview中显示数据行到Cloumns的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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