I need to add orkut like functionality on my site. When user Logs in he should see images of all of his contacts. When he clicks on an image his profile should be loaded. I need guidance achieving this. Presently I have created the hyperlink images at runtime in a table control but not able to load its profile.

This is the broad question and it is not possible for me to explain all theses things in details but you can do so using TemplateField easily.

Following is my code:
Aspx Page
---------

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
      <ContentTemplate>
         <asp:Image ID="imgUser" runat="server" BorderColor="Red" BorderStyle="Solid" 
         BorderWidth="2px" ImageUrl="~/Images/4th_worxxx.gif" Width="120px"  />
      </ContentTemplate>
</asp:UpdatePanel>

Code behind
------------------

protected void lstPerson_SelectedIndexChanged(object sender, EventArgs e)
    {
        hdnSelectedPerson.Value = lstPerson.SelectedItem.Text;
        String ImageName = "";
        ds = RU.Load(hdnSelectedPerson.Value);   //get the Dataset containing the record of the current User.
        if (ds.Tables[0].Rows.Count > 0)
        {
            ImageName = (String)ds.Tables[0].Rows[0]["Image"];
            if (ImageName.Equals(""))
                imgUser.ImageUrl = "~/Images/4th_worxxx.gif";
            else
                imgUser.ImageUrl = "~/Images/" + (String)ds.Tables[0].Rows[0]["Image"];
        }            
    }
        //Code to populate the Grid with images
        private void ShowFriendsInGridView()
    {
        // Retrieve the connection string stored in the Web.config file.
        String connectionString = DB.MyConnectionString;
        String queryString;
        DataSet ds = new DataSet();
        try
        {
            queryString = "Select Firstname,lastname,image from person";
            SqlConnection connection = new SqlConnection(connectionString);
            SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection);

            // Fill the DataSet.
            adapter.Fill(ds);
            if (ds.Tables.Count > 0  )
            {
                Image i = new Image();
                i.ImageUrl = "~/Images/" + (String)ds.Tables[0].Rows[ImageCounter]["image"];
                i.Height = 70;
                i.Width = 70;
                i.ToolTip = (String)ds.Tables[0].Rows[ImageCounter]["Firstname"];
                PnlImages.Controls.Add(i);
            }

        }
        catch (Exception ex)
        {
            // The connection failed. Display an error message.
            //Message.Text = "Unable to connect to the database.";
        }
    }

Any better solution is most appreciated.
Thanks in Advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.