472,353 Members | 1,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

How to change and image?

Hello,

i know how to hide a table according to a condition:
<table runat="server" visible='<%# dataSetBibliotecas.FieldValue("Titulo",
Container) <> "" %>'...

Now I am trying to change the image file as follows:
- Show the image "yes.gif" if the value of a dynamic field is equal to
"YES";
- Show the image "no.gif" if the value of a dynamic field is equal to "NO".

Do you think this is possible? Can you help me out?

Thank You,
Miguel
Nov 18 '05 #1
3 1769
Hi Miguel,

Don't forget that you can use an IIF inside a template item. In the
following code, the IIF checks the value of the "Boolean" field and returns
the English or French button depending on whether the value is true or
false. You could probably adapt this technique to your Yes and No image
locations.

Does this help?

Ken
Microsoft MVP [ASP.NET]
<asp:DataGrid id="DataGrid1" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Image id="Image1" runat="server"
ImageUrl='<%# IIf(DataBinder.Eval(Container,
"DataItem.Boolean"),"http://www.gc.ca/images/englishbt.gif","http://www.gc.ca/images/francaisbt.gif")
%>'>
</asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
DataGrid1.DataSource = CreateDataSource()
DataGrid1.DataBind()
End If
End Sub

Function CreateDataSource() As ICollection
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("PercentValue", GetType(Double)))
dt.Columns.Add _
(New DataColumn("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 0.23 * (i + 1)
If i = 5 Then
dr(3) = False
Else
dr(3) = True
End If

dt.Rows.Add(dr)
Next i
Dim dv As New DataView(dt)
Return dv
End Function 'CreateDataSource

"Miguel Dias Moura" <we****@27NOSPAMlamps.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello,

i know how to hide a table according to a condition:
<table runat="server" visible='<%# dataSetBibliotecas.FieldValue("Titulo",
Container) <> "" %>'...

Now I am trying to change the image file as follows:
- Show the image "yes.gif" if the value of a dynamic field is equal to
"YES";
- Show the image "no.gif" if the value of a dynamic field is equal to
"NO".

Do you think this is possible? Can you help me out?

Thank You,
Miguel


Nov 18 '05 #2
Thanks,

i will try it now.

P.S: about not answering to some posts - sometimes they disapear in my
Outlook. The oldest ones. So when i am going to check them out they are not
there.

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:#J**************@TK2MSFTNGP10.phx.gbl...
Hi Miguel,

Don't forget that you can use an IIF inside a template item. In the
following code, the IIF checks the value of the "Boolean" field and returns the English or French button depending on whether the value is true or
false. You could probably adapt this technique to your Yes and No image
locations.

Does this help?

Ken
Microsoft MVP [ASP.NET]
<asp:DataGrid id="DataGrid1" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Image id="Image1" runat="server"
ImageUrl='<%# IIf(DataBinder.Eval(Container,
"DataItem.Boolean"),"http://www.gc.ca/images/englishbt.gif","http://www.gc.c
a/images/francaisbt.gif") %>'>
</asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
DataGrid1.DataSource = CreateDataSource()
DataGrid1.DataBind()
End If
End Sub

Function CreateDataSource() As ICollection
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("PercentValue", GetType(Double)))
dt.Columns.Add _
(New DataColumn("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 0.23 * (i + 1)
If i = 5 Then
dr(3) = False
Else
dr(3) = True
End If

dt.Rows.Add(dr)
Next i
Dim dv As New DataView(dt)
Return dv
End Function 'CreateDataSource

"Miguel Dias Moura" <we****@27NOSPAMlamps.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello,

i know how to hide a table according to a condition:
<table runat="server" visible='<%# dataSetBibliotecas.FieldValue("Titulo", Container) <> "" %>'...

Now I am trying to change the image file as follows:
- Show the image "yes.gif" if the value of a dynamic field is equal to
"YES";
- Show the image "no.gif" if the value of a dynamic field is equal to
"NO".

Do you think this is possible? Can you help me out?

Thank You,
Miguel

Nov 18 '05 #3
Thanks,

i will try it now.

P.S: about not answering to some posts - sometimes they disapear in my
Outlook. The oldest ones. So when i am going to check them out they are not
there.

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:#J**************@TK2MSFTNGP10.phx.gbl...
Hi Miguel,

Don't forget that you can use an IIF inside a template item. In the
following code, the IIF checks the value of the "Boolean" field and returns the English or French button depending on whether the value is true or
false. You could probably adapt this technique to your Yes and No image
locations.

Does this help?

Ken
Microsoft MVP [ASP.NET]
<asp:DataGrid id="DataGrid1" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Image id="Image1" runat="server"
ImageUrl='<%# IIf(DataBinder.Eval(Container,
"DataItem.Boolean"),"http://www.gc.ca/images/englishbt.gif","http://www.gc.c
a/images/francaisbt.gif") %>'>
</asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
DataGrid1.DataSource = CreateDataSource()
DataGrid1.DataBind()
End If
End Sub

Function CreateDataSource() As ICollection
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("PercentValue", GetType(Double)))
dt.Columns.Add _
(New DataColumn("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 0.23 * (i + 1)
If i = 5 Then
dr(3) = False
Else
dr(3) = True
End If

dt.Rows.Add(dr)
Next i
Dim dv As New DataView(dt)
Return dv
End Function 'CreateDataSource

"Miguel Dias Moura" <we****@27NOSPAMlamps.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello,

i know how to hide a table according to a condition:
<table runat="server" visible='<%# dataSetBibliotecas.FieldValue("Titulo", Container) <> "" %>'...

Now I am trying to change the image file as follows:
- Show the image "yes.gif" if the value of a dynamic field is equal to
"YES";
- Show the image "no.gif" if the value of a dynamic field is equal to
"NO".

Do you think this is possible? Can you help me out?

Thank You,
Miguel

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Irvin Amoraal | last post by:
I am new to javascript coding. I am using some javascript code to change an image on an html page. I would like the user to click on the image to...
1
by: Spike | last post by:
Hello! Im going to make a javascript for changing alot of images. But im not sure how to do it., where to start.. Ok, first.. this is the isue....
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does...
2
by: Ben | last post by:
Hi. I have a button that change a number of images src's when I click a button. The src's are stored in an array and I just use document.src=pics...
2
by: Nick Calladine | last post by:
Is this possible to ... I wish to get the value of a dropdown select but gets is indexable value (dont know if that is the right term) if that is...
1
by: Anthony Boudouvas | last post by:
Hi to all, i have a treeview that i put some nodes in it with their repsective images. If i try to change the image and set it to some other...
2
by: Sanjeeva Reddy | last post by:
hai Anti Keskinen, i have used the following code MyListView->LargeImageList->ImageSize = gcnew System::Drawing::Size(100, 100); // Sets large...
6
by: ruca | last post by:
Hi gurus, I have a imagebutton in my WebForm, and I want that when I click (mouse down) on her the imagebutton change image and when I "unclick"...
3
by: vj | last post by:
how to change images based on action. Even clicking changed images should do respective actions. and while displaying only one image at a time...
8
by: miladhatam | last post by:
can i change the size of a file dynamically ? for example have 100 Kb and i want to decrease it to 20 Kb thanks
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.