如何在从asp.net中的数据库派生的gridview的行上创建超链接? [英] How to create hyper links on rows of gridview that is derived from database in asp.net?

查看:85
本文介绍了如何在从asp.net中的数据库派生的gridview的行上创建超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个网站,其中使用了网格视图表并从数据库表类别中检索了数据,如下所示:
数据库表类别

I m making a website in which i have used grid view table and retrieved data from database table category as shown down :
Database table category

我想在行上创建链接,例如家庭旅行,宗教旅行,冒险旅行,特殊事件旅行,国家公园,并且每当在表超链接中创建新行时,都应在其上自动创建..我应该如何做请帮忙....谢谢
我想在红色标记内的数据上创建链接

I want to create link on rows i.e family tours ,religious tour ,Adventure Tours,Special Event Tours,National Park and whenever new row is created in table hyperlink should be created automatically on it .... How should I do it Please do help .... thank you
I want create link on data that is inside the red mark

推荐答案

非常感谢您的帮助@Rana Ali 我有一个更简单的方法,只需编写此代码即可完成,希望对其他人也有帮助:)

Thank you for your help really appreciate your help @Rana Ali I have got a more simplified method that can be done by just writing this code I hope this will help others as well :)

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataSourceID="SqlDataSource1" GridLines="None" Height="300px" 
    Width="100px">
    <Columns>
        <asp:BoundField DataField="Cat_name" HeaderText="Category" 
            SortExpression="Cat_name" >
        <HeaderStyle Font-Bold="True" Font-Italic="True" 
            Font-Names="Lucida Calligraphy" Font-Size="X-Large" ForeColor="#3399FF" />
        <ItemStyle Font-Bold="True" Font-Italic="True" Font-Size="Small" />
        </asp:BoundField>
        <asp:HyperLinkField DataTextFormatString="View" DataTextField="Cat_url" DataNavigateUrlFields="Cat_url" HeaderText=""  />
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ToursandTravelsConnectionString %>" 
    SelectCommand="SELECT [Cat_name], [Cat_url] FROM [category]">

这是上面代码的输出:

这篇关于如何在从asp.net中的数据库派生的gridview的行上创建超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆