转换数据列将数据库中的值转换为超链接列 [英] convert data column getting values from the database into hyperlink column
本文介绍了转换数据列将数据库中的值转换为超链接列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将数据列转换为超链接列,在单击时导航到指定的页面。每个单元格的导航页面都不同...这里是代码..
< asp:GridView ID = gvDept runat = server AllowSorting = True
< span class =code-attribute> AutoGenerateColumns = False BorderWidth = 1px CellPadding = 1 CellSpacing = 1
PagerSettings-Visible = true
宽度 = 100% >
< HeaderStyle CssClass = whr-GridHead VerticalAlign = 顶部 HorizontalAlign = 中心 / >
< RowStyle CssClass = whr-Grid / >
< AlternatingRowStyle CssClass = whr-GridAlt / >
< 列 >
< asp:BoundField DataField = DeptCode HeaderText = 部门代码 ItemStyle-HorizontalAlign = 中心
< span class =code-attribute> ItemStyle-Width = 5% 可见 = true >
< ItemStyle HorizontalAlign = 中心 < span class =code-attribute> 宽度 = 5% / >
< / asp:BoundField >
< asp:BoundField DataField = DeptDescription HeaderText = 部门名称 ItemStyle- HorizontalAlign = 中心
< span class =code-attribute> < span class =code-attribute> ItemStyle-Width = 5% 可见 = true >
< ItemStyle < span class =code-attribute> HorizontalAlign = 中心 宽度 = 5% / >
< / asp:BoundField >
< / Columns >
< / asp:GridView >
在此先感谢...
解决方案
查看以下代码部分,可能会有所帮助:
< columns>
< asp:hyperlinkfield xmlns:asp = #unknown >
DataNavigateUrlFields = UserId
DataNavigateUrlFormatString = userProfile.aspx?ID = {0}
DataTextField = < span class =code-string> UserName
HeaderText = 用户名
SortExpression = UserName />
< / asp:hyperlinkfield > < / 列 >
另外,你可以在这里找到一个完整的讨论: http://forums.asp.net/t/1086879.aspx [ ^ ]
通过以下链接研究尝试在您的代码中实现...
在ASP.NET中的GridView中创建HyperLinkField的实用指南 [ ^ ]
I want to convert a data column into a hyperlink column which navigates to a specified page when clicked..navigation pages are different for each cell...here is the code..
<asp:GridView ID="gvDept" runat="server" AllowSorting="True"
AutoGenerateColumns="False" BorderWidth="1px" CellPadding="1" CellSpacing="1"
PagerSettings-Visible="true"
Width="100%" >
<HeaderStyle CssClass="whr-GridHead" VerticalAlign="Top" HorizontalAlign="Center"/>
<RowStyle CssClass="whr-Grid" />
<AlternatingRowStyle CssClass="whr-GridAlt" />
<Columns>
<asp:BoundField DataField="DeptCode" HeaderText="Department Code" ItemStyle-HorizontalAlign="Center"
ItemStyle-Width="5%" Visible="true">
<ItemStyle HorizontalAlign="Center" Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="DeptDescription" HeaderText="Department Name" ItemStyle-HorizontalAlign="Center"
ItemStyle-Width="5%" Visible="true">
<ItemStyle HorizontalAlign="Center" Width="5%" />
</asp:BoundField>
</Columns>
</asp:GridView>
Thanks in advance...
解决方案
Look at the following part of code, maybe it will help:
<columns> <asp:hyperlinkfield xmlns:asp="#unknown"> DataNavigateUrlFields="UserId" DataNavigateUrlFormatString="userProfile.aspx?ID={0}" DataTextField="UserName" HeaderText="User Name" SortExpression="UserName" /> </asp:hyperlinkfield></columns>
Also, you can find a full discussion here: http://forums.asp.net/t/1086879.aspx[^]
go through following link study it try to implement in ur code...
Practical Guide for Creating HyperLinkField in GridView in ASP.NET[^]
这篇关于转换数据列将数据库中的值转换为超链接列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文