Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










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:
Forms Data Controls :: Display An Icon In Gridview Whose Value Is Depending Upon Another Column Value?
I want to display an icon(image) in a gridview column which depends on the value of another column.I want to do that dynamically.How to change the imageurl dynamically.

Posted: Mar 13, 2007 06:52 AM

View 9 Replies!   View Related
Forms Data Controls :: Display An Icon Image In Gridview Depending On The Returned Data
I have a gridview and would like to display one of 5 icons depending on the value returned from the database for that row (simply just A, B, C, D or E). Which event in my datagrid should I be looking at to check what value I'm getting? I presume once I can check a value I can simply set an image source using if statements?

Posted: Aug 13, 2010 04:19 PM

View 4 Replies!   View Related
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
Forms Data Controls :: How To Update Row On Editable Gridview Depending On Two Column
Solved like this

currentID = Convert.ToInt32(GridView_ABC.DataKeys[0].Values[0]);
activityName = Convert.ToString(GridView_ABC.DataKeys[1].Values[1]);
DataRow row =
originalDataTable.Select(String.Format("EmployeeID = {0} AND ActivityName = '{1}'", currentID, activityName))[0];

Posted: Jun 29, 2010 10:54 AM

View 1 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 Changing Visibility Depending On A Row.text?
[Code]....

and im not getting the result i expected=

Posted: Oct 18, 2010 07:15 PM

View 5 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 tomake header red and it works fine.How to make it such that the rows also turn red if condition ismet ? 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. Theselabels 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
Forms Data Controls :: >>>want To Display Gridview Column Heading When Mouse Over To The Particular Column In The Gridview?
I want to display gridview column heading when mouse overto the particular column inthe gridview.I am working in VisualStudio 2005 with MS.Net2.0 framework.I don't want to use ajax.

Posted: Oct 12, 2010 08:50 AM

View 4 Replies!   View Related
Forms Data Controls :: >>>Display Gridview Column Heading When MouseOver On Particular Column?
want to display gridview column heading when mouse overto the particular column inthe gridview.

Posted: Oct 12, 2010 08:49 AM

View 9 Replies!   View Related
Forms Data Controls :: Display Text In 2 Rows And Then A Gridview Column - Third Row Is Displayed As A Row Under First Column
I havea gridview with 3 columns. In second column I want to display some text in 2 rows and then a gridview.
Here is my code:

[Code]....

The problem is my third row is displayed as a row under first column. How do I make it a separate column in my girdview. Not sure what is going wrong.

Posted: Jul 14, 2010 04:33 PM

View 11 Replies!   View Related
Sum The Column Values Of Gridview And Display In Footer Column?
I have gridview control with auto generate column.i dont have template columns.the columns will bind dynamically with gridview. i need to sum the all dynamic columns and have to display in footer column.

Posted: Jun 10, 2009 12:45 PM

View 3 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
Forms Data Controls :: Display GridView Columns Data Depending On Conditions?
using DetailsView DataRowView i am able to get current row and based on conditions display specific column's data within DetailsView control.

Here is the source;

[Code]....

How can i achieve the same in GridView?

Posted: Nov 24, 2009 06:02 PM

View 7 Replies!   View Related
Web Forms :: Display Popup When Clicked On Image Datagrid Column?
Displayed image(template column) in datagrid columnfrom 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
Forms Data Controls :: Display Image In Gridview From Sql Image In .Net 2005
I need to Display the Image directly from SQL Database in the GridView as Thumnails. This i can do in .Net 2003 with Help of ItemDatabound Event and Template Column. But in the .Net 2005 there no ItemDatabound event in GridView.

Posted: Mar 14, 2007 05:07 AM

View 3 Replies!   View Related
Forms Data Controls :: Display Default Image When Image (file) Not Found GridView - ImageField
I have a page which displays detailsanda pictures of employees. The details arestored in a SQL database and the images are on the server. How can I set a default Image to display(e.g. an Image saying "Awaiting Image") ifan employee picture is missing?

I can't use NullImageUrl as the Images are not stored in the database. I can't use the solutionfound on [URL] asan ImageField does not accept an ID attribute.

[Code]....

Posted: Mar 26, 2010 09:05 PM

View 7 Replies!   View Related
Forms Data Controls :: Gridview - Display A Image Button To Display Date
i have a gridview binded with data when i hover mouse to row i want to display a image button to display date ,and when i click the button i want to display calender control for choose date, and next step after i choose date it will be must insert into database. and mean while a hidden label control will display and date shuld be display in it

Posted: Sep 07, 2010 09:03 AM

View 2 Replies!   View Related
Enlarge The Image In A Gridview Column?
anybodycanhelp 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 ofother document types (some are required and some are not). While the master document's status is "Draft" I need to ignore all notnullable 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
Display Gridview Column As Row?
display gridview column as row?

[code]....

Posted: Feb 4 at 15:08

View 1 Replies!   View Related
Gridview Column Display Order
I am binding a Gridview to a custom object. But the order of fields displayed is not correct. Is there any way to set the fields display order when binding a Gridview to a custom object?

Posted: Mar 8 at 11:44

View 3 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 notbe indented a bit, like an expanded child node in atree.

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
Forms Data Controls :: Show/Hide Edit Button Depending On Column Value?
Show/Hide Edit button depending on column value?

Posted: Dec 15, 2010 09:52 PM

View 3 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
Forms Data Controls :: Inserting Image In A Databound Gridview Column?
I have a data bound column in grid view. When a particular value in a cell is getting processed I want to display an image in the cell.

Posted: Apr 06, 2010 05:20 AM

View 2 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 Total Column In Gridview?
I have a gridview that is an Invoice with four columns, ItemID, Description, Price, Quantity but I want to add another column thatmultiplies theUnitPrice by the Quantity. Themath thing is easy, but what type of column do I create and how do I display it.

Posted: Nov 23, 2009 08:31 PM

View 6 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 :: Gridview Row - Display A Column Value Using Javascript
These are the part of the javascript:

var gridViewCtl2 = null;
var selRow = null;
var gridViewCtlName2 = 'GridView2';
gridViewCtl2 = document.getElementById(gridViewCtlName2);
selRow = gridViewCtl2.rows[2];

Now I want to diaply a particular column (eg. 5th column) into a HTML text box or asp control (Label).

eg.

Text1.value = selRow.......

How can I do that?

Posted: Mar 21, 2011 12:29 AM

View 6 Replies!   View Related
Forms Data Controls :: How To Display Gridview Column Number
how to retrieve the column number in gridview

i am able to get the row number using this syntax <%# Container.DataItemIndex + 1 %>

but what about column number?

Posted: Feb 20, 2011 05:41 PM

View 3 Replies!   View Related
Want An Image On Aspx Pages To Change Depending On The User Who Logs On
i want an image on my aspx pages to change depending on the user who logs on.

Posted: Aug 07, 2009 12:49 PM

View 7 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
Forms Data Controls :: Display Without Rounding Off In Gridview Bound Column
I am having trouble with displaying double data in gridview bound coulumn. I want it to display as it is... But it gets rounded off when displayed.

Like my 1.34 displays 1.00
1.57 - 2.00

and so on. But i want it to display as it is i mean with decimal points, without rounding it off.

Posted: May 17, 2010 10:11 AM

View 11 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved