Click here to Skip to main content
12,296,307 members (62,254 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET SQL
I want to change the image in gridview .

When the conditions in database are satisfied, then the column is true, otherwise false.
and m fetching image for true and false...
then how can i do this in asp.net using sql???
Posted 13-Feb-13 1:02am
mona_12384
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

http://www.aspdotnet-suresh.com/2011/01/how-to-insert-images-into-database-and.html[^]

It's not that you're looking for, but you can certainly have your own logic for your question.. And have a reference from given link !!

Goog Luck !
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

You can include an image control in itemtemplate of gridview. Then in the imageUrl property you can call a function like:
<asp:image id="myImage" runat="server" imageurl="<%#SetImageUrl("DataBaseCondition")%>" />
Now in your code behind implement SetImageUrl(string _databaseCondition) function to set the url of the image.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Hi,
you must handle it at DataBase end.

Select t.Id, t.Name, CASE WHEN Flag = true THEN '~/Images/true.png' ELSE '~/Images/false.png' END from Table t

[Edit: Removed begging for votes]
  Permalink  
v2
Comments
mona_12 14-Feb-13 1:40am
   
How can i bind this image to gridview?
i used image control in item template, but image is mot dispalying.
Asim Mahmood 14-Feb-13 1:45am
   
Dear
Select t.Id, t.Name, CASE WHEN Flag = true THEN '~/Images/true.png' ELSE '~/Images/false.png' END as ImagePath from Table t

use it like this and bind image with this PATH
mona_12 14-Feb-13 1:55am
   
i tried this.
m not storing this image in database. then how can i do this ?
and i used image control. bt still image is not displayed.
Asim Mahmood 14-Feb-13 4:02am
   
please send me your code i'll tell you what you have to do Thanks.
syedasim8@hotmail.com
it's my email id or paste your code here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100