📄 从一个页面中传过id在另一个页面上的控件上显示2.txt.txt
字号:
原页面:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" PageSize="20" Width="761px" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCreated="GridView1_RowCreated" CaptionAlign="Top" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%--编辑摸板--%>
<%-- 加入一个超连接设置他的url 和text jid={0}的意思是按每行分别取值并传送--%>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Jid", "~/jokerdetals.aspx?jid={0}") %>'
Text='<%# Eval("Jname") %>' BorderStyle="None" Height="19px" Width="459px"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Jtime" HeaderText="发表时间"/>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<PagerSettings Visible="False" />
</asp:GridView>
目标页面:
private void list()//显示笑话信息和发表人时间函数
{
string jid;//定义一个变量接收传过来的变量
jid = Request["jid"].ToString();//给他副传过来的变量值
SqlConnection con = db.ceratcon();
con.Open();
SqlCommand cmd = new SqlCommand("select Jcount ,Jtime,Jperson from Joker where Jid='"+jid+"'",con);//wher条件取出相应的内容
cmd.Parameters.Add("@Jid", SqlDbType.VarChar);
cmd.Parameters["@Jid"].Value = Request.QueryString["jid"].ToString();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
this.labelxount.Text = Convert.ToString(sdr["Jcount"].ToString());
this.Labelname.Text = "发表时间为:" + sdr["Jtime"].ToString() + "发表人为:" + sdr["Jperson"].ToString();
}
con.Close();
}
<a href='{0}"'><img></img></a> 在超连接中加图片
girdview,在绑定格式中输入
<a href="{0}"><a scr="" /></a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -