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. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 17
Get it on Google Play
Get it on Apple App Store

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

Similar Artilces:

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

ajax control in data presentation controls
can i add ajax controls (MaskedEdit) to presentation controls (dataGrid, dataForm)?? Hi,of course. But keep in mind that those controls are extenders, so you append them to an existing control. Just convert your GridView / DetailsView-fields into templated fields and add the extender you'd like to use to the controls.RegardsMarco Buerckel Don't forget to mark posts that were helpful as answers. Actually, if you looked at the source code for the Masked Edit Extender, you'd see  [TargetControlType(typeof(TextBox))]Meaning, targeting any control type other than textboxes...

data presentation controls (how to call the individual controls)
Hi please help me.,i have this question., example i create a site with one control, like textbox. when i double click on the white page, the page load event, in the intellisense, the textbox is visible, but when a formview with a textbox inside, in the same page load event, intellisense, the textbox is not available. how can i do the simple intellisense calling where the textbox is just outside a data presentation control like formview. i mean by this intellisense calling is in VB code view., thanks JFRBPH12™  The textbox is within the formview then you can find it like this...

Data presentation without a data control
The Gridview and Formview controls provide good functionality in some circumstances but are clumsey in others. As a newbie to .NET I was wondering if its appropriate to do databinding with textboxes and other data controls outside of one of the new data controls (formview, gridview, etc). Or is it a new standard to always use one of the new data controls. If the answer is yes, would you still use an SQLDatasource, or would you set up the connection in code? And, how would you deal with the syntax? In the Formview we have: <asp:TextBox ID="fnameTextBox" runat="server" ...

Run an event whose control is located in Data Presentation Controls
Hey, How can we fire an event which belongs to such as a button which is located in Data Presentation Controls such as a gridview.For example : Assume that my page contains a gridview control which is contains a button and the button name comes from database by gridview control but i wanna fire button control's own event independently of the GridView. Thanks and Regards.I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)] Hi:   You can use CommandArgument to distinguish different buttons in the same column: <asp:Button ID="Button2&...

Theming the ControlStyle for BoundField controls within data presentation controls.
Hi all, I was wondering if you can set a default width for template fields and/or BoundField controls within a GridView or  DetailsView / FormView controls? I can change the control widths of bound data control fields, including template fields, by setting the ControlStyle. But if I have a bunch of fields in a DetailsView control for example, it's a pain to have to set the ControlStyle property for each field. I would like to do it in one fell swoop. If I add the following to my skin file, then I get server control rendering errors on my pages. The controls can't be rendered becuase I...

Getting Information from the Controls (TemplateField or BoundField ) from any of the Data Presentation Controls
Hello Everybody,I have a very important question for me.For example, I have a GridView.It has three BoundFields and one TemplateFieldI want to get information from any of the record (row,line etc ) using any of the BoundFields or TemplateFields.And also I want to accomplish this not only with GridView but also other Data Presentation Controls, DetailsView FormView and Repeater.Shortly, Can anybody help me how to refer Controls in GridView, FormView, DetailsView, RepeaterPS: I have searched in Google and many sites,forums. But I couldn't see any solution and see that many people ask the same ...

Tracing data controls within data controls
I have a problem with tracing data controls within data controls. Below are the codes and the trace statements. Can anyone help me? Your help is very much appreciated. : : : private void InitializeComponent() { this.DataGrid1.ItemDataBound+=new DataGridItemEventHandler(DataGrid1_ItemDataBound); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e) { DropDownList Dropdownlist1 = (DropDownList)e.Item.Controls[2].FindControl("D...

Using Data Control in another data control
Hey, How to use a SqlDataSource control in a GridView and so on...I mean i wanna show data which comes from UserTables in a gridview whoses data comes from ContentTable so they are two separated tables. Thanks and Regards...I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)] I mean how to use nested gridview controls. Please aren't there any poeple who can help me ?I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)] Try the links below, they might be of some help to you.http://msdn2.microso...

How to add the data present in the controls to a table control without any database involvement.
Hi All,i am four controls where i will write the text and once i click the add button those should get added to the table .i want 6 columns fixed in the table and rows as many as required.i tried doing that taking a table server control and able to load the table.but the problem is whenver i am adding a new row the old one is gfetting overwritten by this and at the end i am getting only one row.  System.Web.UI.WebControls.Table t1 = new System.Web.UI.WebControls.Table();  i have declared the below one global TableRow tr; TableCell tc1; TableCell tc2; TableCell tc...

How do I bind data to a control in the CreateUserWizard control?
Hi,  Does anybody know of any example of how to bind data to a control in the CreateUserWizard control? I found some good articles on customizing the the CreateUserWizard control but none of them give me an example of going to a database table and binding that data retrieved to custom list control like a drop down list to display to the user in the CreateUserWizard control? Thanks!! I found some examples of how to do this, although I wish I knew what is the prefered way to customize or extend membership data, ie your own membership provider, or just writing to a table af...

Data Presentation Controls and complex data+logic
I'd like to know how people solve problem of binding complex data to data presentation controls. As we all know, real life is not as simple as webcasts etc. assume.Lets say we have something like this.List<Person> liPerson = PersonFactory.GetAllPersons();List<Company> liCompany = CompanyFactory.GetAllCompany();And I want a table something like this:Microsoft      Bill      JohnIBM      Ted      CharlesNokia      Matti Is there a generic solution to...

Visibility control of Panel control and its affect on data controls
Thought I would toss this out here this morning and perhaps someone else had run across the same issue and had found a good way to accomplish what I want. First let me state what I'm attempting to do and the problem that I've run into.  GridView1 has a collection of rows in a SQL table that I want to present to the user. I've provided them the options of sorting and selecting only from the GridView control.  Orgionally, I had created a detail view that was being presented in Edit mode and then customized the layout of the edit item template to suit my needs.&nbs...

Image Buttons on Data Presentation Controls
I have set up my Gridview/Detailsview For Commandfields I wanted to use buttons: <ASP:COMMANDFIELD buttontype="Image"                   headertext="Manage Contents"                   updateimageurl="~\Images\UpdateButton.jpg"                   cancelimageurl="~\Images\CancelButton.jpg"         ...

Web resources about - Bind Data to an Image Control not in a Data Presentation Control -

Presentation High School - Wikipedia, the free encyclopedia
... 121°54′W  /  37.283°N 121.900°W  / 37.283; -121.900 Coordinates : 37°17′N 121°54′W  /  37.283°N 121.900°W  / 37.283; -121.900 Presentation ...

authorSTREAM App Brings PowerPoint Presentations To Facebook
PowerPoint presentations aren’t just for conference rooms anymore, as Facebook application authorSTREAM allows users to upload presentations ...

Presentation Shows Facebook Ad Product Roadmap: Page Metrics, Real Time Ads, No Banners
A document accidentally revealed by a Facebook advertising partner in Poland provides new details on the company’s ad product roadmap. The presentation ...

Lessonator: Create music slideshow presentations
Lessonator is a tool for creating beautiful music slideshow presentations on your Mac. It works like a mashup between Apple’s Keynote and Garageband, ...

Scripting News: Create a presentation in Fargo.
... move my whole act over there, but in the meantime, here's a pointer to my latest piece. ...

12 Minutes To Create a Mind-Changing Presentation
Reading this blog article will take you only 12 minutes — 12 minutes to find out how to draft great presentations and to become a more effective ...

App Store - SlideShark: View & Share Presentations
Get SlideShark: View & Share Presentations on the App Store. See screenshots and ratings, and read customer reviews.

Leaked presentation reveals the Nexus 6P will feature a big 3450mAh battery
Someone has just leaked an official Google presentation for the Huawei Nexus 6P, giving us many more details on the upcoming higher-end Nexus ...

Football Manager 2016 review: Presentation makes perfect
At one point it was all going smoothly. Inspired by Jurgen Klopp, my Liverpool team was playing a high-pressure, high-tempo game that even the ...

PowerPoint Presentation of the Darned
... PowerPoint deck from Jeb’s recent “Imma Tell My Mom, Dad and Big Brother You Were MEAN to Me” conference. There are 112 slides in the presentation. ...

Resources last updated: 11/27/2015 9:31:35 AM