如何动态更改gridview列中的更改。 [英] How do make changes in a gridview column dynamically.
问题描述
我的代码中有一个数据表。我从sql server获取数据。在数据表中我有列(状态)。
此状态列有2个值(C,A)。
例如:
ID状态
1 C
2 A
3 C
4 A
但我想向用户显示
ID状态
1已取消
2已批准
3已取消
4已批准。
ins in showin雕像C或A我想显示为已取消或已批准。
请在添加到gridview之前告诉我如何更改此数据表列。
先谢谢。
在数据库上创建一个表,让它称为status_table,包含2个字段 - status_id(主键)和status_desc,包含以下数据:
[status_id] [status_desc]
A已批准
C已取消
我们说你的桌子我你的问题被称为table1,将status_table的status_id的主键链接到table1中的状态字段(外键),然后,触发以下查询,
SELECT table1.id,status_table.status_desc FROM table1在table1.status上加入status_table = status_table.status_id
将输出绑定到数据表然后将gridview绑定并完成
I have a data table in my code. I'm getting data from sql server. In the datatable I have column("Status").
This Status column has 2 values ("C","A").
ForExample:
ID Status
1 C
2 A
3 C
4 A
But I would like to show to the user as
ID Status
1 Cancelled
2 Approved
3 Cancelled
4 Approved.
Insted of showin the statue "C" or "A" I would like to show as "Cancelled" or "Approved".
Kindly let me know how to change this datatable column before appending to gridview.
Thanks in Advance.
On the database, create a table, let call it "status_table" with 2 fields - status_id (primary key) and status_desc with the following data:
[status_id] [status_desc] A Approved C Cancelled
Let's say your table in your question is called table1, link the primary key of status_id of the "status_table" to the status field (foreign key) in table1, then, fire the following query,
SELECT table1.id, status_table.status_desc FROM table1 join status_table on table1.status = status_table.status_id
bind the output to the data table and then the gridview and it is done.
这篇关于如何动态更改gridview列中的更改。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!