在GridView中显示具有两个不同值的相同字段 [英] displayng same field with two different values in gridview
问题描述
大家好...
我有一个gridview,其中显示了发票上的商品税.
所以在数据库中我有一个税表,其中有"taxid"和"taxname".
因此,对于1号发票,假设有两种税款:增值税和服务税.
所以我想在gridview中显示税名,这将从税表中获取..
问题在于,Gridview在绑定时仅采用数据库列名称.
所以我怎么能显示具有两个不同值的一列呢?
即
我想要这样
发票| tax1id | tax1name | tax2id | tax2name
-------------------------------------------------- ----
1 2增值税3服务
2 1销售2增值税
而我
发票| tax1id | tax1name | tax2id | tax2name
-------------------------------------------------- ----
1 2增值税3增值税
2 1销售2销售
谢谢n问候
Rohit.
hello every one...
I have a gridview in which i am showing taxes added on goods in invoice.
so in database i have tax table in which i have ''taxid'' and ''taxname''.
so suppose for invoice no 1 there are two taxes VAT and Service.
so i want to show that taxes names in gridview which i will get from tax table..
Problem is that gridview only takes database column names while binding.
so how can i show one column with two different values..??
i.e.
I want like this
Invoiceno | tax1id | tax1name | tax2id | tax2name
------------------------------------------------------
1 2 VAT 3 SERVICE
2 1 Sales 2 VAT
and i m geting
Invoiceno | tax1id | tax1name | tax2id | tax2name
------------------------------------------------------
1 2 VAT 3 VAT
2 1 Sales 2 Sales
Thanks n regards
Rohit.
推荐答案
问题是表结构本身是错误的.您应该标准化表格.
让我们考虑一下您商品上的税项增加了,在这种情况下,您可能必须添加另一列,例如tax2id和tax3name.
相反,我建议您规范化表结构.
使用表结构,如
The thing is that your table structure itself is wrong. You should normalize the table.
Let''s consider that tax items on your goods get increased, in that case, you may have to add another column like tax2id and tax3name.
Rather I''d suggest you to normalize the table structure.
Use table structure like
InvoiceNo | TaxId | TaxName
------------------------------
1 2 VAT
1 3 SERVICE
2 1 Sales
2 2 VAT
在检索数据的同时,您可以拥有一个名为"Group By"的子句.
And while retrieving the data, you can have something called ''Group By'' clause.
这篇关于在GridView中显示具有两个不同值的相同字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!