I am using ASP.NET 3.5. I have to show images or text based on some conditions inside gridview.The images are being generated from CLOB data from Oracle table with the help of EasybyteToHTML.dll .I am able to generate the images dynamically on my E drive
that is not my application's directory D . (because for application's directory, we do not have permission to make these image) .
For a single record( not in gridview) I am able to render these images on browser on my report.aspx page by using a
img tag, whose source(src tag) is imagesource.aspx page.This imagesource.aspx is single page which show single image from E drive.
But when I add this img tag inside gridview template, I get only one image on browser bkoz imagesource.aspx ' s page load gets fired only once.I want different images for diffrent rows based on some condition and those conditions I have given in rowdatabound
event of gridview.
Basically I want to ask that how to show images into gridview row which exist in other directory.On condition basis , the row cell can be populated simply from text fields or from image.
Can anyone would plz let me know how to handle this situation ?
Basically I want to ask that how to show images into gridview row which exist in other directory.On condition basis , the row cell can be populated simply from text fields or from image.
Put a image control in a Template Field>ItemTemplate and bind its ImageUrl property to filed where the image names are stored. Also put a label control in the same item template with whatever text you needto show Or binding its text property to the field
you need to show as follows
Thanks for your reply. I fixed this issue by putting img control in gridview template and making run at server .I gave its src as new page imagesource.aspx which renders a image from my E drive. I passed image names by query string in rowdatabound event
like
img.Src=imagesource.aspx?imagename=myImageName
Marked as answer by ravikumarhbti on May 30, 2012 07:03 PM
ravikumarhbt...
Member
56 Points
24 Posts
Show images in GrivView from diffrent directory other than application's directory
May 27, 2012 06:03 PM|LINK
Hi,
I am using ASP.NET 3.5. I have to show images or text based on some conditions inside gridview.The images are being generated from CLOB data from Oracle table with the help of EasybyteToHTML.dll .I am able to generate the images dynamically on my E drive that is not my application's directory D . (because for application's directory, we do not have permission to make these image) .
For a single record( not in gridview) I am able to render these images on browser on my report.aspx page by using a img tag, whose source(src tag) is imagesource.aspx page.This imagesource.aspx is single page which show single image from E drive.
But when I add this img tag inside gridview template, I get only one image on browser bkoz imagesource.aspx ' s page load gets fired only once.I want different images for diffrent rows based on some condition and those conditions I have given in rowdatabound event of gridview.
Basically I want to ask that how to show images into gridview row which exist in other directory.On condition basis , the row cell can be populated simply from text fields or from image.
Can anyone would plz let me know how to handle this situation ?
Ravi
basheerkal
Star
10672 Points
2426 Posts
Re: Show images in GrivView from diffrent directory other than application's directory
May 27, 2012 07:06 PM|LINK
Put a image control in a Template Field>ItemTemplate and bind its ImageUrl property to filed where the image names are stored. Also put a label control in the same item template with whatever text you needto show Or binding its text property to the field you need to show as follows
<asp:TemplateField> <ItemTemplate> <asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/YourFolder/"+ Eval("your_Image_Field") %>' /> <asp:Label ID="Label1" runat="server" Text= "No Image"></asp:Label> </ItemTemplate> </asp:TemplateField>And use this code
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Image img = (Image)(e.Row.FindControl("Image1")); Label lbl = (Label)(e.Row.FindControl("Label1")); if (img.ImageUrl == "~/YourFolder/No Image") { img.Visible = false; lbl.Visible = true; } else { img.Visible = true; lbl.Visible = false; } } }Apply conditions in RowdataBound event
(Talk less..Work more)
ravikumarhbt...
Member
56 Points
24 Posts
Re: Show images in GrivView from diffrent directory other than application's directory
May 30, 2012 07:03 PM|LINK
Hi
Thanks for your reply. I fixed this issue by putting img control in gridview template and making run at server .I gave its src as new page imagesource.aspx which renders a image from my E drive. I passed image names by query string in rowdatabound event like
img.Src=imagesource.aspx?imagename=myImageName