如何在gridview列中显示不同的数据类型值 [英] How to show different data types values in gridview column

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

问题描述



我有gridview,显示数据库表中的数据包含Id,Name和Inventory列。

其中

库存列应包含类似<   pre     lang   =  vb >  

$ 50.00
寄售
寄售
$ 100.50 < / pre >

这里我的网格有编辑功能如果库存列中没有货币值,则用户可以将字符串作为寄售插入。为此,我可以在表中存储一个静态值,但我的问题是如何处理代码隐藏(C#.net)以获取数据类型和条件寄售字符串

解决方案

50.00
寄售
寄售


100.50 < / pre >

如果没有货币值,我的网格有编辑功能库存列用户可以将字符串作为寄售插入。为此,我可以在表中存储一个静态值,但我的问题是如何处理代码隐藏(C#.net)以获取数据类型和条件寄售字符串


< blockquote>您需要将Inventory列更改为字符串数据类型,这应该在从数据库获取数据时在查询中完成。 转换(varchar(100),库存)作为库存您可能还想添加一些格式。然后在您的代码中,您可以插入寄售或在查询中执行此操作。


Hi,
I have gridview that shows data from database table contains columns as Id,Name and Inventory.
Among this

Inventory Column should contain data as like <pre lang="vb">

$50.00
Consignment
Consignment
$100.50</pre>

Here my gird has edit features if there is no currency value in Inventory column user can insert string as Consignment. For this i can store in table one static value but my problem is how to handle in codebehind(C#.net) for getting datatypes and conditions  "Consignment" string in

解决方案

50.00 Consignment Consignment


100.50</pre> Here my gird has edit features if there is no currency value in Inventory column user can insert string as Consignment. For this i can store in table one static value but my problem is how to handle in codebehind(C#.net) for getting datatypes and conditions "Consignment" string in


You need to change Inventory column to a string data type, this should be done in the query when getting the data from the database. Convert(varchar(100),Inventory) as Inventory you may also want to add some formatting. Then in your code behind you can insert "Consignment" or do this in the query as well.


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

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