日期:2014-05-18  浏览次数:20465 次

GridView 与 DataGrid编码的问题
我在后台代码里进行了类似于  
<a   href= 'test.htm '> aa </a>
然后用GridView   与   DataGrid分别显示
结果DataGrid可以正常显示出连接点
而GridView里显示的却是
&lt;a   href= 'test.htm '&gt;aa&lt;/a&gt;

如何解决呢?

------解决方案--------------------
<asp:GridView PageSize= "15 " cssclass= "DataGridStyle " BorderWidth= "1px " BorderColor= "Silver " ID= "gdvInfo " runat= "server " AutoGenerateColumns= "False " AllowPaging= "True " DataKeyNames= "RoleID " OnPageIndexChanging= "gdvInfo_PageIndexChanging " CellPadding= "4 " ForeColor= "#333333 " OnRowDeleting= "gdvInfo_RowDeleting " OnRowEditing= "gdvInfo_RowEditing ">
<Columns>
<asp:TemplateField HeaderText= "角色名称 " SortExpression= "RoleName ">
<ItemTemplate>
<a href= ' <%# Eval( "RoleID ", "RoleDefine.aspx?cmd=View&&id={0} ") %> '> <%#Construct(Eval( "RoleName ").ToString())%> </a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField= "RoleDesc " HeaderText= "角色描述 " SortExpression= "RoleDesc " />
<asp:HyperLinkField Text = "&lt;img src=../../images/button/userright1.gif width=16 height=16 border=0 alt=浏览、设置该角色的权限信息 /&gt; " DataNavigateUrlFields= "RoleID " DataNavigateUrlFormatString= "RightSetting.aspx?id={0} " HeaderText= "权限 " HeaderStyle-Width= "40px "/>
<asp:HyperLinkField Text = "&lt;img src=../../images/button/userright2.gif width=16 height=16 border=0 alt=浏览、设置该角色的用户界面 /&gt; " DataNavigateUrlFields= "RoleID " DataNavigateUrlFormatString= "RoleInterfaceRel.aspx?id={0} " HeaderText= "界面 " HeaderStyle-Width= "40px "/>
<asp:TemplateField HeaderText= "编辑 ">
<ItemTemplate>
<asp:ImageButton runat= "server " ID= "btnEdit " ImageUrl= "~/Images/button/edit.gif " CommandName= "edit " ToolTip= "更改角色信息 "/>
</ItemTemplate>
<HeaderStyle Width= "40px " />
</asp:TemplateField>
<asp:TemplateField HeaderText= "删除 ">
<ItemTemplate>
<asp:ImageButton runat= "server " ID= "btnDelete " OnClientClick= "return confirm( '确定要删除? '); " ImageUrl= "~/Images/button/delete.gif " CommandName= "Delete " ToolTip= "更改角色信息 "/>
</ItemTempl