Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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

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 !
 
Share this answer
 
You can include an image control in itemtemplate of gridview. Then in the imageUrl property you can call a function like:
ASP.NET
<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.
 
Share this answer
 
v2
Hi,
you must handle it at DataBase end.

SQL
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]
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900