Display Image In Gridview Depending On Value Of Column?
I have a gridview which displays rows and columns all linked to an sql statement... and all works as normal.
I want to include a new column, that displays an image depending on what the value of the column is. If the column has a value - it will display an image. If the column value is null no image whill be displayed.
My sql is something like:
SELECT c.call_id, title, a.call_id as b_attach
FROM calls c
LEFT JOIN attachments a ON c.call_id = a.call_id
GROUP BY c.call_id,title,description, a.call_id
What's returns from this sql is:
Call_id | title | b_attach
1235 | title goes here | 1235
1382 | another title |NULL
So if there's something in b_attach - diplay image in gridview column, else display nothing in gridview column
My Gridview:
[Code]....
View 1 Replies (Posted: Dec 2 10 at 12:18)
Sponsored Links:
Related Forum Messages For ASP.NET category:
Web Forms :: Display Image (im1/img2) Depending Upon Db Value?
i have a database with a field for 'hasimage' with values true/false. if it is true i want to display img1 and if false i want to display img2. currently i have a single static image which takes user to the url. code aspx: <a runat="server" id="hlkmail"> <img src="../images/send_mail_icon.jpg" alt="" /></a> <a>Send<br /> Mail</a> code aspx.vb: hlkmail.href="remail.aspx?clientname="&clientname now, i want to use the db value and accordingly display img1 / img2, onclick of which will take the user to the url.
Posted: Dec 27, 2010 06:31 AM
View 5 Replies!
View Related
Web Forms :: How To Display Image Depending Upon Db Field Value
this is my aspx page code : <a runat="server" id="hlkmail"><img src="../images/send_mail_icon.jpg" alt="" /></a> <a runat="server" id="hlkgallery"><img src="../images/galleryl_icon.jpg" alt="" /></a> this is code behind (aspx.vb) : hlkmail.HRef = "sndmail.aspx?Clientname=" & clientName hlkgallery.HRef = "pgallery.aspx?Clientname=" & clientName above code shows fixed images. i want to display image dynamiccally depending upon the db value. i have a stored proc that returns hasmail ='true/false' and hasgallery='true/false' from database. if true i want to display send_mail_icon.jpg else send_mail_icon_watermark.jpg and gallery_icon else gallery_icon_watermark.jpg. i want to do this in code behind using if loop.
Posted: Dec 29, 2010 08:57 AM
View 7 Replies!
View Related
Change An Individual Image In A Gridview Depending On A Value?
i have 2 tables assignment and feedback, in a gridview it displays all the assignments, the assignments then get feedback. im then wanting to change the view feedback button in the gridview depending on if there is new feedback for example: the feedback table has a state field in it so when its 1 i want that image button to change to the one with the +
Posted: Mar 5 at 19:11
View 1 Replies!
View Related
Forms Data Controls :: Gridview Column Formatting Depending On Text In Header?
I want if the header of a particular column contains a word "S", the header and row turns red. I used following code to make header red and it works fine. How to make it such that the rows also turn red if condition is met ? I cannot hardcode in columns since the Gridview is autogenerate colums as data structure keeps changing. Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)Dim HeaderRow As GridViewRow = GridView1.HeaderRowFor Each c As TableCell In HeaderRow.CellsIf c.Text.EndsWith("S") Then c.BackColor = Drawing.Color.OrangeRed End If Next End Sub
Posted: Mar 30, 2010 03:57 AM
View 2 Replies!
View Related
Forms Data Controls :: TemplateField Change Itemtemplate Label CSS Depending On Column Value For Each Row In Gridview?
I was wondering if anyone could help me. I have a template field which has four itemtemplates that each hold a label in a gridview. These labels are always constant with the same strings. What I want to do is change the css formatting of these four labels depending on the value of a column. So the css formatting would have to be done for each row, not the whole column. I bind the gridview to a dataaccesslayer so there is no sqldatasource on the page. Does anyone have any idea how to do this and where it would be done. I will have the dataview with the data sorted in the correct order. The actual column that is used to alter the CSS will not be in the gridview although I could assign it to the datakeyname if that makes it easier as the data is not sensitive.
Posted: Jan 28, 2011 10:48 AM
View 1 Replies!
View Related
VS 2008 Image In GridView / Display Images In The Gridview From The Image Folder
I have a folder named img containing some images: I want to display images in the Gridview from the image folder in this way: But without saving the image location in the Database (i.e;i want to do this using the System.IO) I can fetch the names of all the images present in the "img" folder but my problem is i cant set the src of the <img> tag properly which would display the image here is what i did: [code]....
Posted: Jul 25th, 2010, 06:28 AM
View 6 Replies!
View Related
Web Forms :: Display Popup When Clicked On Image Datagrid Column?
Displayed image(template column) in datagrid column from db.Now..I need a popup-LIKE window to display this image in bigger size if possible and some other info which I have in code This is somewhat related to asp.net and javascript (I think so) Mainly, the page should not reload when clicked on image column of datagrid. Or it is possible through ajax also.....but dont know ajax(haven't done anything using this)
Posted: Nov 14, 2009 10:44 AM
View 1 Replies!
View Related
Enlarge The Image In A Gridview Column?
anybody can help to enlarge the image in a gridview column. Please look my code given below and please help. At the moment mouseover is not working . Also where I can wrte the function to show the image. I am using a template column and its databound with 'FilePath' column in table. FilePath just stoing the location of the image. <% @ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="frmWhoAmI.aspx.cs" Inherits="learn.frmWhoAmI" %> < </ < asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">asp:Content>asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" DataSourceID="SqlDataSource1" Width="1025px" AllowPaging="True" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2"> <RowStyle BorderStyle="Groove" BackColor="#FFF7E7" ForeColor="#8C4510" /> <Columns> <asp:BoundField DataField="ObjectName" HeaderText="Name" SortExpression="ObjectName"> <ItemStyle Width="600px" /> </asp:BoundField> <asp:BoundField DataField="ObjectDate" HeaderText="Date" SortExpression="ObjectDate"> <ItemStyle Width="250px" /> </asp:BoundField> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description"> <ItemStyle Width="600px" /> </asp:BoundField> <asp:TemplateField HeaderText="Picture"> <ItemTemplate> <a href="javascript:;" onmouseover = "javascript:void(ShowDIV('<%# Eval("FilePath")%>'));" > <asp:Image ID="Image1" runat="server" ImageUrl='<%# "ImageHandler.ashx?ImID="+ Eval("FilePath") %>'/> </a> </ItemTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /> <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /> <EditRowStyle BorderStyle="Groove" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [ObjectName], [ObjectDate], [Description], [FilePath], [ObjectType] FROM [LearnPlus].[WhoAmI]"> </asp:SqlDataSource> function callFxToZoomIn(obj) { obj.parentNode.style.width = "100%"; obj.parentNode.style.height = "100%"; } </ asp:Content>
Posted: Jul 02, 2009 06:13 AM
View 6 Replies!
View Related
Displaying Image In Gridview Column?
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 [Code].... 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
Posted: Mar 30 at 23:12
View 1 Replies!
View Related
SQL Server :: Dynamic Nullable Columns Depending On The Value Of A Column?
I have a master document which is composed of other document types (some are required and some are not). While the master document's status is "Draft" I need to ignore all not nullable constraints (because the writer may decide to work on one of the children documents that is not required and save as draft). The closest solution I found for this problem is check constraints but I have not yet to see an example of this in check contraint and I'm not even sure if this is possible. Has anyone implemented a similar solution with check constraints (or any other methods)?
Posted: Feb 11, 2011 01:33 PM
View 2 Replies!
View Related
How To Display A Gridview Column Only To Users In A Certain Role
I have an asp.net page with a gridview. I would like to make it so that certain columns in the gridview are displayed only if the user is in a certain role, that is, if HttpContext.Current.User.IsInRole(XXX) returns true. What is the easiest way to do this? I would prefer a solution where I can easily put this in my ASP code and not in the page code-behind.
Posted: Dec 2 10 at 23:42
View 2 Replies!
View Related
Forms Data Controls :: Gridview Contain An Image And Text In The Same Column?
I have a 1-column gridview (and it must remain 1-column) which contains only text. My requirement is to prefix each row with an image followed by the text. The image may or may not be indented a bit, like an expanded child node in a tree. I know a gridview renders as a table and I know I could put an image at the beginning of each row in a table (using a repeater, for example). But this is an existing app with a couple gridviews which need to be enhanced and I don't have the time to swap out the gridviews for repeaters.
Posted: Oct 05, 2010 07:03 PM
View 2 Replies!
View Related
Forms Data Controls :: Displaying Image In A Gridview Column?
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 <asp:imagefield dataimageurlfield="IMG" dataimageurlformatstring = "~/images/ab.jpg"/> 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
Posted: Mar 30, 2011 10:53 PM
View 5 Replies!
View Related
Display A Gridview Using Select Statement Of Two Column In One Table?
I'm using asp.net and c# language. How can i display a GridView using select statement of two column in one table? This is my coding: if (sdr.Read()) { if(namaPembekal.Equals(sdr["namaPembekal"]) && tarikhRo.Equals(sdr["tarikhRo"])) { Session.Add("namaPembekal",sdr["namaPembekal"]); Session.Add("tarikhRo", sdr["tarikhRo"]); if((((String)(Session["namaPembekal"])).Equals("namaPembekal")) && ((String (Session["tarikhRo"])).Equals("tarikhRo")) GridView1.DataSourceID = SqlDataSource2.ID; GridView1.DataSourceID = txtJourneyDate.Text; }
Posted: Oct 24 10
View 1 Replies!
View Related
C# - Addition Of Two Columns Display Its Result In Third Column Of Gridview?
Rate AnodeRate TotalRate 100 100 200 txtrate,txtanoderate n txttatalrate are added in ItemTemplate of gridview. rate field is in database table while anoderate n totalrate not in database table ,also totalrate is readonly so that user can see only its addition,this addition will b passed to txtrate field n wil get bind that value in database. also i took <asp:HiddenField ID="hdnTotalRt" runat="server" /> as it is readonly.. sample code: enter code here <asp:TemplateField HeaderText="Standard Rate"> <ItemTemplate> <asp:TextBox ID="txtRate" runat="server" BorderWidth="0.5pt" Text='<%# Bind("rate") %>' BorderColor="green" BackColor="#ffffcc" Width="40px"></asp:TextBox> [Code].... It is showing me error as The name "txtRate"does not exist in d current context
Posted: Jan 5 at 11:06
View 1 Replies!
View Related
How To Add An HttpHandler For Image Extensions That Depending Whether A Variable In The Web.config
I am in the process of moving all of the images in my web application over to a CDN but I want to easily be able to switch the CDN on or off without having to hard code the path to the images. My first thought was to add an HttpHandler for image extensions that depending whether a variable in the web.config (something like ) will serve the image from the server or from the CDN. But after giving this a little though I think I've essentially ruled this out as it will cause ASP.NET to handle the request for every single image, thus adding overhead, and it might actually completely mitigate the benefits of using a CDN. An alternative approach is, since all of my pages inherit from a base page class, I could create a function in the base class that determines what path to serve the files from based off the web.config variable. I would then do something like this in the markup: <img src='<%= GetImagePath()/image.png' /> I think this is probably what I'll have to end up doing, but it seems a little clunky to me. I also envision problems with the old .NET error of not being able to modify the control collection because of the "<%=" though the "<%#" solution will probably work.
Posted: Mar 27 10 at 19:49
View 8 Replies!
View Related
Forms Data Controls :: Display GridView Column / Row Binding
I have a table with the following structure: Attribute ------------- AttributeId WeekNo DayNo Attribute1 Attribute2 Attribute3 Attribute4 Attribute5 ........ likewise. I want to display these data in a gridview in the following manner Sunday Monday Tuesday ............ (till Saturday) - should be gridview columns, I can retrieve this using dayno Attribute 1 Attribute 2 Attribute 3 Attribute 4 like wise attributes should be taken in to rows.Is this possible in a gridview, if so how can I do that?
Posted: Sep 14, 2010 08:35 AM
View 1 Replies!
View Related
Forms Data Controls :: Display Column Wise Records In GridView?
My requirement is i have to display column wise records in GridView control. I am thinking to create a user control for this. See the attachment of sample screen. Sandeep My requirement is i have to display column wise records in GridView control. I am thinking to create a user control for this. See the attachment of sample screen. Sandeep
Posted: Aug 05, 2010 11:47 AM
View 3 Replies!
View Related
|