Click here to Skip to main content
15,894,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :

VB
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900