在GridView中换行 [英] Make a new line in a GridView

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

问题描述

我有一个ASP.Net 2.0 Gridview控件,可以绑定List< T>.对于List< T>中的特定字段也是如此.例如旧"和新",我想放置换行符,将文本分成单独的行,例如:

I've an ASP.Net 2.0 Gridview control that I can bind a List<T> too, for a specific field in List<T> like "Old" and "New" I want to place new line characters that will break the text into separate lines e.g.:

Column1=Value1 Column2=Value2

成为:

Column1=Value1
Column2=Value2

推荐答案

我猜有两种方法可以做到这一点:

I guess there are two ways to do this:

  1. 使用字符串连接将两列合并为一个字段(例如:column1 + '<br>' + column2),以更改列表的格式设置方式.例如,如果您使用的是SQL,则可以使用带有字符串连接的查询(更多信息)

  1. Change the way your List is formatted, using string concatenation to join the two columns into one field (something like: column1 + '<br>' + column2). If you're using SQL, for example, you can use a query with string concatenation (more info)

使用gridview的事件:OnDataBound和/或OnRowDataBound更改在gridview控件中查看数据的方式. (更多信息)

Use the gridview's events: OnDataBound and\or OnRowDataBound to change how data is viewed in the gridview control. (more info)

这篇关于在GridView中换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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