|
|
Subject:
Display an Image in a DataGrid using VB.Net
Category: Computers > Programming Asked by: bdwgarth-ga List Price: $5.00 |
Posted:
23 Jun 2004 11:27 PDT
Expires: 23 Jul 2004 11:27 PDT Question ID: 365171 |
I am developing a web application with Visual Studio.Net using VB.Net page language. I would like to display an image, approximately 50 x 50 pixels in size, in one of the columns of the datagrid. I have the filename for the images stored in database. Currently the filename appears in the datagrid, but I would like the picture to be displyed instead. I am looking for the code that would go in the HTML for the datagird control, and also the VB.net code to get the image and display it in the datagrid. Thank you | |
|
|
There is no answer at this time. |
|
Subject:
Re: Display an Image in a DataGrid using VB.Net
From: jangel-ga on 24 Jun 2004 07:08 PDT |
Insert a placeholder image and use this code for the 'databinding': DataBinder.Eval(Container.DataItem, "yourDBcolumn") |
Subject:
Re: Display an Image in a DataGrid using VB.Net
From: bdwgarth-ga on 30 Jun 2004 08:58 PDT |
This works but... I have this line of code in my HTML but the images have to be in the root directory where the aspx page runs. <asp:Image Width="90" Height="60" runat="server" ImageUrl= '<%# DataBinder.Eval(Container.DataItem, "Picture") %>'> I dont want the files to be in the root directory, so I am looking for a function or some type of string format that will access the path were the images are located. Protected Function GetImageUrl(???) As String Dim ImagePath As String ImagePath = "http://www.website.com.temp/" Return ImagePath End Function ImageUrl= '<%# GetImageUrl(DataBinder.Eval(Container.DataItem, "Picture")) %>' I tryed something like this but it did not work. Any suggestions Thanks |
Subject:
Re: Display an Image in a DataGrid using VB.Net
From: sleepychristoph-ga on 05 Jul 2004 15:15 PDT |
Use a template column e.g. <asp:TemplateColumn runat="server" HeaderText="Photo"> <itemtemplate> <img runat="server" width="50" visible=TRUE 'Or could be function which evaluates if picture exists src='<%# "YourPathHere" + DataBinder.Eval(Container.DataItem, "YourDBColumn") %>' /> </itemtemplate> </asp:TemplateColumn> You can find good examples here : http://msdn.microsoft.com/msdnmag/issues/02/01/cutting/default.aspx |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |