如何使用逗号分隔在Asp.net中的Gridview中显示数据库值。 [英] How do I Show Database Values in Gridview in Asp.net with Comma Seperated.

查看:81
本文介绍了如何使用逗号分隔在Asp.net中的Gridview中显示数据库值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在aspx页面显示数据库中的数据

as

Name1,Class1,Address1,[delete]

Name2,Class2,Address2,[删除]



我正在使用Gridview显示数据,因为我也需要删除和编辑按钮。

为此,我将每个数据库值连接,并隐藏Gridview的网格线

,然后获取Gridview内的值。

一切都很好仍然,

但我面临问题,因为数据的长度不相等。由于数据之间存在空白,因此gridview的单元格正在扩展。如下所示



Nameeeeee,Class1AAAAA,   地址,[删除]

   姓名,    Class2A,Addressssssss,[删除]



如何删除gridview单元格之间的空格。

请协助。或者还有其他方法可以做到这一点。

Hi
I want to Show the Data from Database in aspx page
as
Name1,Class1,Address1,[delete][edit]
Name2,Class2,Address2,[delete][edit]

I am Using Gridview to show the data as i also Need delete and edit button.
For this I Concatenate "," with each database value and Hide the gridlines of Gridview
and then fetched the values Inside Gridview.
All is fine Still,
But I am facing Problem,Because the data are not of equal length .Due to which there are white spaces between data and also the Cell of gridview are expanding. Like below

Nameeeeee,Class1AAAAA,    Addres,[delete][edit]
   Name,    Class2A,Addressssssss,[delete][edit]

How can I remove the Whitespace between the cells of gridview .
Please assist. Or is there any other way to do this.

推荐答案

在sql中连接之前尝试修剪单个字段值,例如:

try trimming the individual field values before concatenating them in sql, example:
SELECT RTRIM(LTRIM(fieldname)) FROM table1



但是,我建议将它们留在gridview中自己的列中。


However, I would suggest leaving them in their own columns in the gridview.


这篇关于如何使用逗号分隔在Asp.net中的Gridview中显示数据库值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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