又一个datagrid的问题

obss 2003-09-29 03:42:05
我数据库(access)一个域中存的是1,2,3,4,代表人民币,美元...
如何在datagrid显示时,显示人民币...而不是1,2,3,4?
...全文
70 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cp07 2003-10-17
  • 打赏
  • 举报
回复
嗯,這個正確!記住在datagrid中定義column.mappingname的時候是
datagrid1.column.MappingName= "xxx"
select f1,f2,case
when f3='1' then '人民币'
when f3='2' then '美元'
end as xxx,f4
from table1

如果你覺得不好的話,可以再建立一個表來存儲幣別,這樣就可以用
Select f1,f2,f3,pay_ccy_name from table1
left outer jion Table_pay_ccy on f3=pay_ccy
居然占用名 2003-09-30
  • 打赏
  • 举报
回复
在ItemDataBound事件中判断值,然后用:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then

' Retrieve the text of the CurrencyColumn from the DataGridItem
' and convert the value to a Double.
Dim strSex As String = e.Item.Cells(3).Text

' Format the value as currency and redisplay it in the DataGrid.
If strSex = "True" Then
e.Item.Cells(3).Text = "上线"
Else
e.Item.Cells(3).Text = "离线"
End If

End If
End Sub
banni2003 2003-09-30
  • 打赏
  • 举报
回复
select f1,f2,case when f3='1' then '人民币'
when f3='2' then '美元' end as xxx,f4.....
from table1
boyors 2003-09-30
  • 打赏
  • 举报
回复
那你就先调个临时表,把数据整理清楚后在和DATAGRID控件连接不就好了。
obss 2003-09-29
  • 打赏
  • 举报
回复
那样不成吧
我的表table1,有很多字段,f1,f2,f3,其中f3为币种,存的是1,2,3,我要在datagrid中显示f1,f2和转换的f3,怎么做?
select f1,f2,f3? from table1
NoReady 2003-09-29
  • 打赏
  • 举报
回复
SLECT 1 AS '人民币',2 AS '美元' FROM TALBE

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧