Display rows in multiple columns in Asp.net Gridvi

2020-07-08 05:17发布

By default each row of a Gridview maps to each row in a datatable or dataset attached to its datasource. But what if I want to display these rows in multiple columns. For example if it has 10 rows, 5 rows each should be displayed in 2 columns side by side. Also can I do this with the Infragistics grid. Is this possible?

3条回答
何必那么认真
2楼-- · 2020-07-08 06:04

You can use a DataList control instead. It has a RepeatColumns property that you can define the number of columns you want to display.

In .NET Framework 3.5, there is an even better solution, the ListView control. You can find further information about how to use the ListView control here.

查看更多
来,给爷笑一个
3楼-- · 2020-07-08 06:04

If this is a pure coding exercise, then bind to the RowDataBound event of the Gridview. That way, you can do:

e.Row.Cells(2).Text = e.Row.Cells(1).Text

This would place the text from column 1 in column 2 after it has been pulled from the database. You can also dynamically create columns using a similar method.

Re-reading, I think I misunderstand your problem though.

查看更多
一纸荒年 Trace。
4楼-- · 2020-07-08 06:17

Can't you just put two identical bound columns one after the other?

查看更多
登录 后发表回答