在网格视图/列表视图中显示链接 [英] show links in grid view/list view

查看:81
本文介绍了在网格视图/列表视图中显示链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!
我正在开发一个网站.我的数据库中有两个表. table1 =用户名,电子邮件
table2 =用户,图片.
我想要的是在一个名为个人资料的链接的gridview/listview中显示所有用户的图片.当我用户单击该概要文件链接时,它将重定向到另一页,并显示table1和table2中的用户概要文件.
请告诉我怎么可能
在此先谢谢您.

hi!
i am developing a website. i have two tables in my database. table1=username,email
table2= userage,pictuer.
what i want is to show all the users picture in a gridview/listview with a link named profile. when i user click on that profile link it redirects to another page and shows the user profile from table1 and table2.
please tell me how is it possible
thanks in advance

推荐答案

我是用这种方式做的.最左边的名为Course No的列在这里充当链接,而 DataNavigateUrlFormatString 在这里将用户重定向到您定义的页面.希望对您有所帮助..
I do it in this way..The left most column named Course No acts as a link here and DataNavigateUrlFormatString here redirects user to your defined page.I hope it helps you..
<asp:GridView ID="GridView1" CssClass="listStyle" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="courseNo">

        <Columns>

            <asp:HyperLinkField HeaderText="Course No" DataNavigateUrlFields="courseNo" DataNavigateUrlFormatString="~/Editing.aspx?courseNo={0}"

             DataTextField="courseNo" HeaderStyle-ForeColor="Maroon" HeaderStyle-BackColor="#ffb8a6" />

            <asp:BoundField DataField="courseTitle" HeaderText="Course Title" HeaderStyle-ForeColor="Maroon" HeaderStyle-BackColor="#ffb8a6"

                SortExpression="courseTitle"  ReadOnly="True"/>

        </Columns>
    </asp:GridView>


您可以像这样使用


You can use like this


<asp:TemplateField HeaderText="Vch/Bill No">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval ("vch") %>' OnClick="LinkButton1_Click"></asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="100px" Height="20px" />
                                <HeaderStyle CssClass="headerstylelist" HorizontalAlign="Center"  />
                         </asp:TemplateField>






并在c#







and in c#


protected void LinkButton1_Click(object sender, EventArgs e)
   {
       LinkButton link = (LinkButton)sender;
       GridViewRow gv = (GridViewRow)(link.Parent.Parent);
       LinkButton CustomerID = (LinkButton)gv.FindControl("LinkButton1");
       Session["vchbill"] = CustomerID.Text;
       Label lbldate = (Label)gv.FindControl("date");
       Label lblparty = (Label)gv.FindControl("party");
       Label lblid = (Label)gv.FindControl("idlbl");
       Session["date"] = lbldate.Text;
       Session["party"] = lblparty.Text;

       SqlCommand cmd = new SqlCommand("select voucher from saleitemdata where vch='" + CustomerID.Text + "' and companyname='" + HiddenField1.Value + "'", con);
       dr = cmd.ExecuteReader();
       if (dr.Read())
       {
           lblid.Text = dr[0].ToString();
           Session["id"] = lblid.Text;
       } dr.Close();
       this.ClientScript.RegisterClientScriptBlock(this.GetType(), "close", "window.opener.location.href='saleitemvoucherbill.aspx', window.close()", true);


       //Response.Write("<script language='javascript'> { window.close();}</script>");
   }



因为这样您可以在新页面中发送会话



beacuse from this you can send session in new page


也请检查此内容
如何在ASP.NET的gridview中添加超链接 [ ^ ]
please check this too
how to add Hyperlink in gridview in ASP.NET[^]


这篇关于在网格视图/列表视图中显示链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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