onclick in .net (vb) is undefined in datalist

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I click in a picture, I get a error the changePicture is undefined

<tr>
<td colSpan="2"><asp:datalist id="Picturelist" runat="server"
RepeatColumns="8">
<itemtemplate>
<img ID="Picture" height=100 width=100 onclick="changePicture"
runat="server" src='<%# DataBinder.Eval(Container.DataItem, "carPicture") %>'
/>
</itemtemplate>
</asp:datalist></td>
</tr>

Public Sub changePicture(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim item As DataListItem =
Picturelist.Items(Picturelist.EditItemIndex)
If (Not item Is Nothing) Then
Dim ddl As DataList = CType(item.FindControl("Picture"), DataList)
Dim check As String = ddl.SelectedItem.DataItem

Dim IDCar As Integer = CInt(Request.Params("CarID"))
Dim Maintenance As MaintenanceDB = New MaintenanceDB

Dim myCarDetails As MaintenanceDetails =
Maintenance.GetACar(IDCar)

Pictureheader.ImageUrl = myCarDetails.CarPictureHeader
End If
End Sub
 
Stanley,

Did you know that there is as well an imagebutton which is in my opinion
very easy to use instead of the image for this..

In my opinion are better newsgroups for this kind of questions by the way
microsoft.public.dotnet.framework.aspnet
and
microsoft.public.dotnet.languages.vb

When you sent messages to both than that no problem when you do not know
what is better for your questions, you can send one message to both
newsgroups in one time (that is called crossposting). However do not send
two message to both one, that is hated by most people in newsgroups.

I hope this above helps anyway directly?

Cor
 
Thanks i got it

<td colSpan="2"><asp:datalist id="Picturelist"
OnItemCommand="Picturelist_ItemCommand" runat="server" RepeatColumns="8">
<itemtemplate>
<asp:ImageButton ID="Picture" height=100 width=100
CommandName="select" runat="server" ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "carPicture") %>' />
</itemtemplate>
</asp:datalist></td>

Sub Picturelist_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs) Handles
Picturelist.ItemCommand
If (e.CommandName = "select") Then
Dim Maintenance As MaintenanceDB = New MaintenanceDB
Dim IDCarPicture As Integer =
Picturelist.DataKeys(e.Item.ItemIndex)
Dim myPictureDetails As MaintenanceDetails =
Maintenance.GetACarpictureUrl(IDCarPicture)
Dim test As String = myPictureDetails.carPicturePathUrl
Pictureheader.ImageUrl = myPictureDetails.carPicturePathUrl
End If
End Sub
 
Back
Top