Bind Data to an Image Control not in a Data Presentation Control

I've been searching for two days but I don't really know what to search for.
I'm making a site for a photographer.  The Default.aspx page displays Albums by showing a title, image and description from the database table Albums. Click an album to view the contents and it passes the QueryString which is AlbumName. 
The ViewAlbum.aspx page uses the QueryString to display an UpdatePanel holding a Large Image and a Repeater full of dynamically filled ImageButtons for thumbs.  Both are from the database table Photos and are retrieved using an ObjectDataSource. Click the ImageButton thumbnail and the CommandArgument (Photo1Path) updates the UpdatePanel and changes the ImageURL for the Large Image.
Here's the problem:  I'd like to be able to show the Album image and description in the place where the Photos will be viewed when we first arrive at the ViewAlbum.aspx page.  The Large Image is not in a Data Presentation Control so I cannot use a DataSource, right?  I tried putting the Large Image in a Repeater and with alot of work on the codebehind I can almost get what I want.  The Album Image appears, and I can click thumbs to get the Photos, but it breaks my UpdatePanel so that I get a full page refresh.
Today I tried working with a MultiView and UpdatePanel, but I could not see how to make them work together to do what I want.
What should I be searching for or trying to do?  "Programmatically Bind Data to Image Control" or "Bind Data in Codebehind" or what?
7/8/2008 6:53:27 PM
📃 72751 articles.

💬 2 Replies

Hi ChibiNopo,
You use QueryString to get parameters from the request. I think when you have the QueryString with parameters, why not use it to do some query and get the ImageUrl for Image control. You can do query for ObjectDataSource, but why not do query for a specific field (imageurl). Then set ImageUrl in Page_Load event.

Qin Dian Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
7/11/2008 3:43:53 AM

Thanks for the reply.
I couldn't figure out how to access the data after so many days of trying that today I cheated.  I added an Object Data Source that uses the Query String to get the data I want.  Then I added a Repeater with Label controls set to Visible = "False" and I used the ItemDataBoundEvent to get the data from the hidden Labels. 
I am sure there is a better way to do it, but I am not much of a programmer.  It works but as I said, I am sure it is not the right way to do it.]
Here is what I ended up with:
protected void Page_Load(object sender, EventArgs e)
        LargeImage2.Visible = false;
    protected void Repeater1_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        LargeImage1.ImageUrl = DataBinder.Eval(e.Item.DataItem, "AlbumImage").ToString();
        Description.Text = DataBinder.Eval(e.Item.DataItem, "Description").ToString();
    protected void Click(object sender, CommandEventArgs e)
        string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
        string ChangeImage1 = commandArgs[0];
        string ChangeImage2 = commandArgs[1];
        string ChangeDescription = commandArgs[2];
        LargeImage1.ImageUrl = ChangeImage1.ToString();
        LargeImage2.ImageUrl = ChangeImage2.ToString();
        Description.Text = ChangeDescription.ToString();
        if (ChangeImage2.ToString() != string.Empty)
            LargeImage2.Visible = true;
Thanks again for the reply.
7/11/2008 3:59:10 AM