Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listview
Message
De
31/03/2008 04:01:34
 
 
À
30/03/2008 04:19:29
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01306686
Message ID:
01306867
Vues:
3
>>>>>>>>>Hi
>>>>>>>>>
>>>>>>>>>I'm using a Listview on a webform. The Listview is getting data from an SQL database. In the database I have an image name (.jpg file)
>>>>>>>>> and I want to display the image in the ItemTemplate on the Listview.
>>>>>>>>>
>>>>>>>>>I can't get the image to display. At the moment I have
>>>>>>>>>
>>>>>>>>>       <ItemTemplate>
>>>>>>>>>            <tr style="">
>>>>>>>>>                <td>
>>>>>>>>>                    <asp:Label ID="lecturerIDLabel" runat="server"
>>>>>>>>>                        Text='< %# Eval("lecturerID") % >' />
>>>>>>>>>                </td>
>>>>>>>>>                <td>
>>>>>>>>>                    <asp:Label ID="LecNameLabel" runat="server" Text='< %# Eval("LecName") % >' />
>>>>>>>>>                </td>
>>>>>>>>>                <td>
>>>>>>>>>                    <asp:Label ID="LecDescLabel" runat="server" Text='< %# Eval("LecDesc") % >' />
>>>>>>>>>                </td>
>>>>>>>>>                <td>
>>>>>>>>>
>>>>>>>>>                  <asp:Image ID="Image1" runat="server" imgurl='< %# Eval("LecPic") % >' />
>>>>>>>>>
>>>>>>>>>                </td>
>>>>>>>>>            </tr>
>>>>>>>>>        </ItemTemplate>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>LecPic contains the name of the image file.
>>>>>>>>>
>>>>>>>>>Any ideas what I'm doing wrong.
>>>>>>>>
>>>>>>>>imgurl?
>>>>>>>>Shouldn't that be ImageUrl ?
>>>>>>>
>>>>>>>Dohhh. Sorry thats my fingers.
>>>>>>>
>>>>>>>changed it but it still didn't work.
>>>>>>>
>>>>>>>FYI in the generated HTML I get src=""AAEAAAD/////AQAAAAAAAAAGAQAAAAZ0dXRvcjEL"" for the image.
>>>>>>>
>>>>>>>Any thoughts
>>>>>>
>>>>>>Just to clarify: The Database contains the *name* of the image file?
>>>>>
>>>>>LecPic contains tutor1.jpg
>>>>Still not clear. Does LecPic contain the string "tutor1.jpg" or the JPG file itself?
>>>>
>>>>>
>>>>>I have a feeling I'm missing something really stupid here
>>>>>
>>>>>the picture URL on the page comes out as
>>>>>
>>>>>http://localhost:52792/tme/adminpages/%22AAEAAAD/////AQAAAAAAAAAGAQAAAAZ0dXRvcjEL%22
>>>>It would normally just be something like:
<img id="Image1" src="tutor1.jpg" />
>>>
>>>
>>>Yes lecpic is a string containing the name of the image file
>>
>>Hmm. I don't have the ability to try using an Eval at the moment but the double double quotes in the src attribute look a bit sus - and the content looks like it might be a string representation of the JPG binary.....
>>Could you try outputting < %# Eval("LecPic") % >' to a textbox or similar to check the value?
>
>Viv
>
>I knew it was something stupid.(that I'd done)
>
>The datasource was a LinqDataSource. When I created the database I did create LecPic as an image data type. Then I created a DataClasses.dbml file. Later decided to change Lecpic to varchar and store the name of the file. Never changed the dbml so it was out of step. So I was trying to process it as an image.

Glad you got it working.
Regards,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform