如何在GridView中显示名称而不是ID
问题描述:
如何在gridview中显示名称而不是表中显示的ID ...
how to display names in gridview instead id''s present in table...
答
问题尚不清楚!
如果您的sql查询如下所示:
Question is Not clear!
If your sql query looks like:
SELECT ID
FROM Table1
只有ID将在gridview中可见,但是如果您这样编写sql查询:
only ID will be visible in a gridview, but if you write sql query like this:
SELECT *
FROM Table1
所有字段都将在gridview中可见.
如果查询返回许多字段(列),则需要用ID
字段隐藏列-如Prasad_Kulkarni所写.
all fields will be visible in a gridview.
If your query returns many fields (columns), you need to hide column with ID
field - as Prasad_Kulkarni wrote.
看起来您正在谈论一个表中的外键,并且您想要来自其他表(即客户表)的FieldName具有AccountID字段,并且您想在网格视图中显示AccountName.
试试:
Looks like you are talking about foreign key in one table and you want FieldName from other table i.e. Customer table is having AccountID field and you want to show AccountName in grid View.
Try :
Select a.CustomerName, a.CustomerAddress, b.AccountName
from tblCustomer a
inner join
tblAccounts b
on a.AccountID=b.AccountID
好吧,我了解您在谈论创建视图,因此与其说视图ID,不应该是视图名称.希望它以任何方式正确.检查此链接
SQL Server 2005中的视图概述 [ ^ ]
http://www.sql-server-performance.com/2004/views-in -sql-server/ [ ^ ]
http://msdn.microsoft.com/en-us/library/aa258253%28v = sql.80%29.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ms187956.aspx [ ^ ]
http://www.sqlinfo.net/sqlserver/sql_server_VIEWS_the_basics.php [
Hi ,
Well i understand you were talking about create view so instead of view ID should view Name Hope it''s Right any way Check this links
Overview of Views in SQL Server 2005[^]
http://www.sql-server-performance.com/2004/views-in-sql-server/[^]
http://msdn.microsoft.com/en-us/library/aa258253%28v=sql.80%29.aspx[^]
http://msdn.microsoft.com/en-us/library/ms187956.aspx[^]
http://www.sqlinfo.net/sqlserver/sql_server_VIEWS_the_basics.php[^]
Best Regards
M.Mitwalli