Hi all...
I've a page in which I've used 5 imageButtons to display 5 user profile. Each time page_load event is called, all those 5 ImageButtons are initialized by some random user id's. To access the profile of user, I stored ther user id of user to the attributes of image button at run-time. To do so I used the following piece of code :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
conClass.Connect()
Dim UserId1 As String = Nothing
Dim sql1 As String = "Select uid,fname from login where num=" RandomNumber
Dim cmd1 As New SqlCommand(sql1, conClass.con) Dim reader1 As SqlDataReader = cmd1.ExecuteReader
While reader1.Read
UserId1 = reader1.GetString(0)
RndPrflImg1.AlternateText = reader1.GetString(1)
RndPrflImg1.Attributes.Item("uid") = UserId1
RndPrflName1.Text = reader1.GetString(1)
End While
reader1.Close()
RndPrflImg1.ImageUrl = Me.GetImagePath(UserId1)
End Sub
The same code is used to load rest 4 profile.
Now to display those profile, I used the following code :
Protected Sub RndPrflImg_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles RndPrflImg1.Click, RndPrflImg2.Click, RndPrflImg3.Click, RndPrflImg4.Click, RndPrflImg5.Click
Dim RndPrflImg As ImageButton = sender
Response.Redirect("profile.aspx?uid=" & RndPrflImg.Attributes.Item("uid"))
End Sub
This code is working but my problem is that, when I clicked on user profile (image button) sometimes it open the profile of another user (instead of same user).
Suggest me what should I do to resolve my problem.
Thanks.
Gagan