GridView的超链接到asp.net中同一网站的另一个页面 [英] GridView's Hyperlink to another page in same website in asp.net

查看:74
本文介绍了GridView的超链接到asp.net中同一网站的另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我只是一个初学者并制作一个网站,在搜索详细信息后,在网格视图中只显示每个人的图像,姓名,年龄和每行上的链接用户将看到该搜索人员的完整个人资料。



因此我想在gridview中使用一个超链接字段,该字段将用户导航到同一网站中的另一个页面。选择一个人的完整细节。

我的问题是超链接如何导航到另一个页面。



请尽快帮助我。

解决方案

使用HyperLink控件。试试

http://www.youtube.com/watch?v=dIKN9vbbUIw [ ^ ]

http://www.mandsconsulting.com/asp- net-hyperlink-in-gridview-using-hyperlinkfield-sqldatasource-boundfield-templatefield-and-hyperlink [ ^ ]


 <   asp:GridView    < span class =code-attribute> ID   =  GridView1    runat   =  server     AutoGenerateColumns   = < span class =code-keyword> False  

< span class =code-attribute> < span class =code-attribute> AllowPaging = True CellPadding = 3 DataSourceID = S qlDataSource1

AllowSorting = BackColor = 白色 BorderColor = #CCCCCC BorderStyle =

< span class =code-attribute> < span class =code-attribute> BorderWidth = 1px >
< >
< asp:TemplateField HeaderText = 个人资料图片 SortExpression = Image_Loc >
< ItemTemplate >
< asp:Image ID = Image1 runat = 服务器 ImageUrl =' <% #Eval( Image_Loc%> '

< span class =code-attribute> < span class =code-attribute> 高度 = 80px 工具提示 = 个人资料图片 宽度 = 70px / >
< / ItemTemplate >
< / asp:TemplateField >
< asp:TemplateField HeaderText = UserId SortExpression = user_id >
< ItemTemplate >
< asp:标签 ID = Label1 runat = server 文字 =' <% #Bind(< span class =code-string> user_id%> ' > < / asp:Label >
< / ItemTemplate >
< EditItemTemplate >
< asp:TextBox ID = TextBox1 runat = server 文字 =' <% #Bind( user_id%> ' > < / asp:TextBox >
< ; / EditItemTemplate >
< / asp:TemplateField >
< asp:TemplateField HeaderText = 角色 SortExpression = role >
< ItemTemplate < span class =code-keyword>>
< asp:Label ID = Label2 runat = server 文本 =' <% #Bind( role%> ' > < / asp:Label >
< / ItemTemplate >
< EditItemTemplate >
< asp:TextBox ID = TextBox2 runat = server 文字 =' <% #Bind( role% > ' > < / asp:TextBox >
< / EditItemTemplate >
< / asp:TemplateField >
< asp:TemplateField HeaderText = 个人资料视图 >
< ItemTemplate >
< asp :HyperLink ID = HyperLink1 runat = 服务器

NavigateUrl =' <% #Eval( user_id ProfileView.aspx?user_id = {0}%> '

文字 =' < img src =Image / view.gif/ >' 工具提示 = 查看您的个人资料 > < / asp:HyperLink >
< / ItemTemplate >
< / asp:TemplateField >
< < span class =code-leadattribute> / Columns
>
< FooterStyle BackColor = 白色 ForeColor = #000066 / >
< HeaderStyle BackColo r = #006699 Font-Bold = True ForeColor = 白色 / >
< PagerStyle BackColor = 白色 ForeColor = #000066 Horizo​​ntalAlign = / >
< RowStyle ForeColor = #000066 / >
< SelectedRowStyle BackColor = #669999 字体-粗体 <温泉n class =code-keyword> = True ForeColor = 白色 / >
< SortedAscendingCellStyle BackColor = #F1F1F1 / >
< < span class =code-leadattribute> SortedAscendingHeaderStyle BackColor = #007DBB / >
< SortedDescendingCellStyle BackColor = #CAC9C9 / >
< SortedDescendingHeaderStyle BackColor = #00547E / >
< / asp:GridView >
< asp:SqlDataSource ID = SqlDataSource1 runat = 服务器

< span class =code-attribute> ConnectionString = <%


ConnectionStrings:tutorConnectionString %>

SelectCommand = SELECT DISTINCT [ user_id],[role],[Image_Name],[Image_Loc] FROM [img] >
< / asp:SqlDataSource >


hello everyone,
I am just a beginner and making a web where after searching the details come in a gridview with only everyone's image , name ,age and a link on each row by clicking on which the user will see the complete profile of that searched person.

thus I want a hyperlink field in the gridview which navigates the user to another page in the same website with that selected one person's complete details.
My problem is the Hyperlink how to navigate to another page.

Please help me as soon as possible.

解决方案

Use HyperLink controls. Try
http://www.youtube.com/watch?v=dIKN9vbbUIw[^]
http://www.mandsconsulting.com/asp-net-hyperlink-in-gridview-using-hyperlinkfield-sqldatasource-boundfield-templatefield-and-hyperlink[^]


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

                                AllowPaging="True" CellPadding="3" DataSourceID="SqlDataSource1"

                                AllowSorting="True" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"

                                BorderWidth="1px">
                                <Columns>
                                    <asp:TemplateField HeaderText="Profile Image" SortExpression="Image_Loc">
                                        <ItemTemplate>
                                            <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Image_Loc") %>'

                                                Height="80px" ToolTip="Profile Image" Width="70px" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="UserId" SortExpression="user_id">
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("user_id") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("user_id") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Role" SortExpression="role">
                                        <ItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("role") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("role") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Profile View">
                                        <ItemTemplate>
                                            <asp:HyperLink ID="HyperLink1" runat="server"

                                                NavigateUrl='<%# Eval("user_id", "ProfileView.aspx?user_id={0}") %>'

                                                Text='<img src="Image/view.gif"/>' ToolTip="View Your Profile"></asp:HyperLink>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <FooterStyle BackColor="White" ForeColor="#000066" />
                                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                                <RowStyle ForeColor="#000066" />
                                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                                <SortedAscendingHeaderStyle BackColor="#007DBB" />
                                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                                <SortedDescendingHeaderStyle BackColor="#00547E" />
                            </asp:GridView>
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server"

                                ConnectionString="<%


ConnectionStrings:tutorConnectionString %>" SelectCommand="SELECT DISTINCT [user_id], [role], [Image_Name], [Image_Loc] FROM [img]"> </asp:SqlDataSource>


这篇关于GridView的超链接到asp.net中同一网站的另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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