通过按ID发送回URL重定向到同一页面 [英] redirecting to same page by post back url by id
问题描述
我正在使用asp.net ImageButton作为回发URL.在user.aspx
页面中,数据列表中有其他用户的图像.
我想要当我单击任何这些图片时,所选用户的详细信息应显示在用户页面上.我该怎么办.
在我的ImageButton
中,我使用像这样的回发网址
I am using an asp.net ImageButton for post back url. In user.aspx
page there are images of other users within a datalist.
I want when I click any of those pictures the selected user s details should display on the user page. What do I have to do for that.
In my ImageButton
I use post back url like this
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl=''<%# GetImageURL(Eval("Pic")) %>'' PostBackUrl=''<%# Eval("id", "user.aspx?id={0}") %>''/>
并在页面中加载代码
and in page load code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Session("UName") Is Nothing Then
Response.Redirect("login.aspx")
Else
If Not (IsPostBack) Then
binddata()
binddata1()
binddata2()
End If
End If
End Sub
并像这样在databind上使用查询字符串
and use query string on databind like this
Sub binddata()
Dim mycommand As New SqlCommand("SELECT * FROM details where id = @id", con)
mycommand.Parameters.Add("@id", SqlDbType.Int)
mycommand.Parameters("@id").Value = Convert.ToInt32(Request.QueryString("id"))
con.Open()
userData.DataSource = mycommand.ExecuteReader
userData.DataBind()
con.Close()
End Sub
但它不起作用.我无法发现我要去哪里错了.请帮助我.
[edit]-格式化的代码块和一些小的语法变化
but it is not working. I am not able to catch where I am going wrong. Please help me with this.
[edit] - formatted code blocks and some minor grammer changes
推荐答案
Try
替换
Try
replacing
PostBackUrl='<%# Eval("id", "user.aspx?id={0}") %>'
与
with
PostBackUrl='<%# Eval(Container.DataItem, "id", "user.aspx?id={0}") %>'
谢谢,
hemant
Thanks,
hemant
这篇关于通过按ID发送回URL重定向到同一页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!