I have image in the image folder and in my oracle database I have a column with the name IMG which has the name of
the image like ab.jpg
I have another column with name IMG1 which is storing the whole url like images/ab.jpg
I can see all the values of my database table in my dataset as well including IMG column and IMG1 column
In my aspx file I wrote code
but it is not displaying anything, however aspx page is working fine, it is showing a field but no image and it is blank, same is
the case with IMG1 column as well
Why is it so? What is wrong that I am doing?
I dont want to store image in database, so i store it in the folder
What method should i adopt to make it work?
Update
thats my code
<Columns>
<asp:BoundField DataField= "DD" HtmlEncode="false" HeaderStyle-BorderColor="green"
HeaderStyle-Font-Bold="true" HeaderStyle-Font-Names="Arial"
HeaderStyle-Width="100%" HeaderStyle-Wrap="true" HeaderText="HEAD"
ItemStyle-Width="100%" >
<ItemStyle BorderColor="green" HorizontalAlign="Center" Wrap="true" />
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="Image1" ImageUrl="~/images/ab.jpg" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CC" HeaderText="SHEET" />
</Columns>
If I look at design section it is giving me image sign with a cross but not showing the actual image
location of image is
I have folder A and there I have sub folder images and mywebpage
so both mywebpage and images folder is in folder A
I have used paths as ~/images/ab.jpg and ~A/images/ab.jpg and in both cases it does not work
Method below does not work either
Using Oracle database, which is showing image url columns on dataset and even on grid as mentioned in my last post
What wrong am I doing?
Any solution?
You haven't share your code but you can use ImageField of GridView and set the DataImageUrlField to your image url.
You can alternatively go with TemplateField if you want more control over manipulation of url.
Sharing your code will have if the above doesn't meet your need.
Edit 1:
Since your page and images folder are in same folder try: ImageUrl="images/ab.jpg"
Although ImageUr"~/A/images/ab.jpg" should have worked.
Also to point sometimes the images might not appear in DesignView, so did you try opening your page in browser?
Related
nesting of image inside a LinkButton shows image on one page & doesn't show image on another page below are two sample code from two different pages in the same root director.It works fine on one page but on the other page is doesn't show any download image rather shows the text download in place of image.
I have done troubleshooting for sometime and replace the code also but it doesnt show download image for any reason on the second page..
<asp:LinkButton ID="lnkbtnDownload" runat="server" onclick="lnkbtnDownload_Click" meta:resourcekey="lnkbtnDownloadResource1">
<asp:Image ID="imgDownload" runat="server" ImageUrl="~/images/download.png" meta:resourcekey="imgDownloadResource1" />
</asp:LinkButton>
<asp:LinkButton ID="lnkbtnDownload" runat="server" onclick="lnkbtnDownload_Click" meta:resourcekey="lnkbtnDownloadResource1">
<asp:Image ID="imgDownload" runat="server" ImageUrl="~/images/download.png" meta:resourcekey="imgDownloadResource1" />
</asp:LinkButton>
HTML OUTPUT
HTML for above two code sample render as below
<img alt="Download" src="images/download.png" id="MainContent_imgDownload">
Download
Both Pages are in the same root directory...
The problem probably comes from a discrepancy in your resource files or missing a resource file completely for the second page. Obviously you have one for the first, but possibly not for the other which has different naming.
If you are using meta:resourcekey, there are some things you have to considerate.
Make sure that your local resource files meet the following criteria:
They are in an App_LocalResources folder.
The base name matches the page name.
For example, if you are working with the page named Default.aspx, the
resource files are named Default.aspx.resx (for the default
resources), Default.aspx.es.resx, Default.aspx.es-mx.resx, and so on.
The resources in the file use the naming convention
resourcekey."property". For example, key name Button1."Text".
Source: MSDN
Why doesn't the image show up when the file extension is THM.
<ItemTemplate>
<asp:image id="ThumbImg" runat="server" imageurl='<%# GeThumb(Container.DataItem) %>' Width ="60px" Height = "60px" />
</ItemTemplate>
The above lines are within asp:gridview in ASPX page.
GetThumb returns url as below.
http://www.xyz.com/images/mythumbnailimage.THM
The image doesn't show on the grid and I don't get to see the typical RED Colored x mark but it is different. In any case the image doesn't show in the grid. The image file exists on the server but will render when I change extension to JPG or TIF.
So my question is what's wrong with THM files. What am I doing wrong here?
Thanks.
Found the image extensions (THM in my case) needs to be added in the server. Added and it started working.
I have a Datagrid on one page, when user clicks on cell of datagrid, it should open another form with labels and textboxes and it should fill it with relevant data fetching from the SQL Database.
I have searched and found out
response.querystring["string"]
But due to its visibility cant use it.
I am pretty new with coding in asp, done some on WINFORM using C#, so I was trying to do through creating an object but it didn't work, so what is the correct way of doing it?
Thanks
I didnt' work with data grid but if it's anythign like gridview then you have an option to use template fields and customize the links for these.
Here is an example template field from grid view that can be customized to suite your needs
<asp:TemplateField HeaderText="Customer Status" SortExpression="IsCustomer">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<a href='yournewpage.aspx?param=<%# Eval("Column_name")) %>' alt="" />
</ItemTemplate>
</asp:TemplateField>
Hope you are having a nice day.
I am developing a gridview for a list of songs with a hyperlink field like below. I left unnecessary codes by the way. The purpose of hyperlink field is for user to download songs. I am using visual studio 2010 and I am still using development server such as http://Localhost:xxxx/mypage.aspx. So I have to update the hyperlink field everytime I run this page in order to keep the link correct. I understand once i put on the live server, i just need to put the domain and this problem is fixed but I am wondering if there is a way to dynamically map the path of DataNavigateUrlFormatString to the development server URL so that I don't need to keep changing while I am on development server.
Thanks a lot.
<asp:GridView>
<Columns>
<asp:BoundField DataField="Song_Name" HeaderText="Song_Name" SortExpression="Song_Name" />
<asp:HyperLinkField DataNavigateUrlFields="Song_Location"
DataNavigateUrlFormatString="http://localhost:6686/RioMusic/Uploads/{0}"
DataTextField="Song_Name" HeaderText="Download" />
</Columns>
</asp:GridView>
Can you just use a relative link? I.e.:
Uploads/{0}
(This will be relative to the page displaying the link.)
Or, if you wish to specify a url relative from the root of your site:
~/RioMusic/Uploads/{0}
suppose my images binary data is saved in database table and i want to show those images through gridview. one approach is just create one page where i will pass some id as query string and that page will retrieve the image data from db and stream down the image data to my page through BinaryWrite method. a example is http://www.aspdotnetcodes.com/Insert_Images_Database.aspx. this url describe how to show image data through BinaryWrite.
this approach is old and i know. is there any other way by which i can show the image in gridview but i don't want to store image url in table.please let me know if you know any other approach for showing the images through gridiview when image binary data is stored in db. thanks
I asked a similar question here:
Streaming Databased Images Using HttpHandler
Note that I had to use a DataReader in my final version :-)
It sounds like you've got your images stored in your database in binary format. You then want to show them in your GridView.
Consider this approach:
create a template field in your gridview to hold your image. It'll end up calling a handler URL to grab the binary data for your image.
create the image handler page -- make it an .ashx. Put a unique identifier on the querystring, for example, to grab the image you want from the database
<Columns>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="80px" Width="80px"
ImageUrl='<%# "ImageHandler.ashx?ImID="+ Eval("ImageID")
%>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
See the answer at the bottom of this MSDN question for more details on how to implement your image handler. You then won't have to bring back the binary data when binding your GridView. On the other hand, it creates n calls to the handler for each row in the grid.