【发布时间】:2011-11-23 14:02:36
【问题描述】:
在我的任何特定用户帐户的 user.aspx 页面中,将所有其他用户名/图像显示为数据列表中的链接以及登录的特定用户信息。现在我希望如果我单击任何其他用户链接用户信息应该出现在同一个 user.aspx 页面上。我在页面加载时使用此代码
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Session("UserName") Is Nothing Then
Response.Redirect("login.aspx")
Else
If Not (IsPostBack) Then
binddata()
binddata1()
binddata2()
End If
End If
End Sub
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()
Data.DataSource = mycommand.ExecuteReader
Data.DataBind()
con.Close()
End Sub
Sub binddata1()
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()
nameimage.DataSource = mycommand.ExecuteReader
nameimage.DataBind()
con.Close()
End Sub
Sub binddata2()
Dim mycommand As New SqlCommand("SELECT * FROM details ", con)
con.Open()
user.DataSource = mycommand.ExecuteReader
user.DataBind()
con.Close()
End Sub
这个脚本用于数据列表
<asp:DataList ID="custom" runat="server" DataKeyField="Name" RepeatColumns="1" >
<ItemTemplate>
<div><table>
<tr><asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# GetImageURL(Eval("Pic")) %>' PostBackUrl='<%# Eval("id", "user.aspx?id={0}") %>'/></tr>
<tr><td align="left" valign="top" style="width:90px"><asp:LinkButton ID="name" runat="server" ForeColor="Blue" Text='<%#Container.DataItem("Name")%>'></asp:LinkButton></td></tr>
</table></div></ItemTemplate>
</asp:DataList>
此代码在第一次检查/单击时运行良好。当我单击其中一个用户时,它会加载用户的详细信息。但在那之后,当我单击另一个用户时,它不会加载该用户的详细信息。我想显示:一个用户登录,然后在他的页面上有其他用户的图像列表。当我单击其中任何一个时,特定的详细信息应加载到适当的位置。帮我解决这个问题
【问题讨论】:
-
我不知道你想要达到什么目标以及你为什么想要?
标签: asp.net data-binding postback