本文介绍了在网格视图/列表视图中显示链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我正在开发一个网站.我的数据库中有两个表. 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
推荐答案
<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>
<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
这篇关于在网格视图/列表视图中显示链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!