Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 30th, 2007, 02:19 AM
Registered User
 
Join Date: Jan 2007
Location: Chandigarh, UT, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jasdeephere
Default How to get the id of an image control

Hi

I am devloping a shopping cart project.
I have datalist on my home page to show items with their images and other details from database.

I have an image control into datalist id = "Image1"
and one more image control on my home page id = "Image2"

When i am trying to retrieve images from database which are in binary format

if i use Image2.imageUrl = "code "
then it works fine and show image in this control at home page.

but i want to show that image into image control into datalist which have the id = "Image1"
So when i use Image1.ImageUrl = " "
this give an error that "Image1 is not declared"

I mean when i try to use the Image1 control in my code behind file it gives an error that "Image1 is not Declared"

Please tell me how can i access this id on my code behind file or how can i use the id of an image control which is in datalist.

Hope the problem is clear to you.
Please Reply it soon. Its very Urgent.

Thanx & Regards
Jasdeep Singh

  #2 (permalink)  
Old January 30th, 2007, 04:18 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well Jasdeep

You cannot directly refer to the image control which is inside the datagrid, you have to first find the control, cast it and then set the src, may be you can do it in the ItemDataBound event as below:

HtmlImage imgShopping;

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                imgShopping = (HtmlImage) e.Item.FindControl("Image1");
                imgShopping.Src = "abc.jpg";

            }

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
  #3 (permalink)  
Old January 30th, 2007, 04:53 AM
Registered User
 
Join Date: Jan 2007
Location: Chandigarh, UT, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jasdeephere
Default

hey MIKE
Thanx for answering.
but sorry to say this hasn't solve my problem.

Let me tell u full scenario then you will better guide me.

I am developing a project on shopping cart.
I have Some Items with their details(id,code,name,price,quantity etc.) into my database in "tbl_items"
I have 1 more table "tbl_images" in this i have images for the above items. The code is same in both tables.

Now i have datalist on my home page.

I made a query with sqldataadapter select * from tbl_items
and bind it with the datalist
and 1 another query which retrieve image with their code and extension from tbl_images

The image stored into a folder in my application and the path has been stored into database in tbl_images table

now i have retrieved that images corresponding to the items but how to bind that image with datalist right after the name of an item.
Please suggest and if not clear my problem you can ask for more clues.

Hope to get a reply very soon.

Thanxs & Regrads
Jasdeep Singh


  #4 (permalink)  
Old January 30th, 2007, 09:06 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well

Thats what I said friend, you have to bind the image's src within the itemdatabound event of your datalist, for e.g. your datalist could be as below:

<asp:DataList Runat="server" id="dlShopping" RepeatColumns="4" RepeatDirection="Horizontal">
                <ItemTemplate>
                    <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td><%=DataBinder.Eval(Container.DataItem,"ImageNa me")%></td>
                        </tr>
                        <tr>
                            <td><img id="Image1" runat="server"></td>
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:DataList>

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Image to Image Control using JavaScript ctranjith General .NET 1 May 28th, 2013 05:43 AM
Getting id of a control in javascript sudhir164 Javascript How-To 2 February 23rd, 2008 05:35 AM
Get the Id of Control in ASP rekha_jsr Classic ASP Professional 2 June 14th, 2006 07:37 AM
html control with same id and name ??? muklee Javascript 1 October 22nd, 2004 12:49 AM



All times are GMT -4. The time now is 10:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.