将超链接放入表格中已经存在的(列)GridView控件的列时出现问题
我正在使用Asp.Net.
问题:我的数据库中有2个表.第一个表是EmpMaster(EmpId,EmpName,Desig)
,第二个表是EmpAddress(EmpName,Address)
.因此,我在default1.aspx页中使用了一个GridView控件来绑定EmpMasater表数据.此处的EmpName列是超链接.当我们单击EmpName列的行时,它将带我们转到其他页面default2.aspx,第二张表已绑定到另一个gridview控件.
我在源文件中编写的代码是
Hi,
I am working with Asp.Net.
Question: There are 2 tables in my database. First table is EmpMaster(EmpId,EmpName,Desig)
and the second table is EmpAddress(EmpName,Address)
. So I used One GridView control in my default1.aspx page to bind the EmpMasater table data. Here the EmpName column is the hyperlink. When we click on the row of a EmpName column it takes us to other page default2.aspx there the second table is bound to another gridview control.
The code I have written in the source file is
<columns>
<asp:BoundField DataField="EmpId" HeaderText="EmpId" SortExpression="EmpId" />
<asp:BoundField DataField="EmpName" HeaderText="EmpName" SortExpression="EmpName"/>
<asp:BoundField DataField="Desg" HeaderText="Desg" SortExpression="Desg" />
<asp:HyperLinkField DataTextField="EmpName" NavigateUrl="~/Default2.aspx"/>
</columns>
这里的问题是,当我运行default1.aspx时,它显示4列.
Problem here is when I run the default1.aspx it show 4 columns.
EmpId EmpName Desg EmpName
--------------------------------
但是我不希望将EmpName超链接作为额外的列.我只希望在第二栏中.
任何人都可以为此提供解决方案.
But I don''t want the EmpName hyperlink as the extra column. I want it in the Second column only.
Can anyone please give the solution for this.
这很简单.您已经使用了3个BoundField列和一个HyperLinkField列,因此显示的总列为4.
但是我不希望将EmpName超链接作为额外的列.我只想要第二列.
删除第二列,然后将"HyperLinkField列"移到第二个位置,您就完成了.
It''s very simple. You have used 3 BoundField Columns and a HyperLinkField Column and so the total columns that are displayed is 4.
But I don''t want the EmpName hyperlink as the extra column. I want it in the Second column only.
Delete the second column and move the HyperLinkField Column to the second position and you are done.
<columns>
<asp:BoundField DataField="EmpId" HeaderText="EmpId" SortExpression="EmpId" />
<asp:HyperLinkField DataTextField="EmpName" NavigateUrl="~/Default2.aspx"/>
<asp:BoundField DataField="Desg" HeaderText="Desg" SortExpression="Desg" />
</columns>
希望这会有所帮助!
Hope this helps!