ASP Gridview(在每行中放入更多项目)? [英] ASP Gridview (put more items in each row)?

查看:80
本文介绍了ASP Gridview(在每行中放入更多项目)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在gridview的每一行中放置多于一项的datarow(来自数据库表),或者这样做?
这是我的示例图片. http://image.free.in.th/show.php? id = 576c4ca3ad11a87887a249b9c01f28e7 [ ^ ]

How can I put more than 1 item of datarow(from table of database) in each row of gridview or is it posible to do that?.

And this is my sample pic..http://image.free.in.th/show.php?id=576c4ca3ad11a87887a249b9c01f28e7[^]

推荐答案

您需要从gridview获取数据源并将该数据源存储在数据表中.
将新行添加到数据表中.
将网格视图的数据源设置为修改后的数据表并绑定数据.

You need to get the data source from your gridview and store the data source in a data table.
Add your new rows to the data table.
Set the data source of the grid view to the modified data table and bind your data.

DataTable dt = (DataTable)GridView1.DataSource;
object[] obj = new object[4];
obj[0] = "Column 1";
obj[1] = "Column 2";
obj[2] = "Column 4";
obj[3] = "Column 3";
dt.Rows.Add(obj);
GridView1.DataSource = dt;
GridView1.DataBind();


您应该使用DataList并将列更改为4.

you should use DataList and change columns to 4.

<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" GridLines="Both" >


这篇关于ASP Gridview(在每行中放入更多项目)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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