J
James Page
Hi all
Have a bit of a problem..
I have a data list and in the item template I have an image button.
The Data list is data bound to sql data:
id
picId
etc...
The data key name for the data list = id
The imageUrl for the image button is bound to picId.
When the image button is clicked I need to get the selectedValue of the of
the item
here's what I've got:
Protected Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs) Handles
DataList1.ItemCommand
If e.CommandName = "test" Then
Dim var1 As String
Dim dl As New DataList
dl = Me.FindControl("DataList1")
var1 = dl.SelectedValue.ToString
End If
End Sub
All i'm getting is a null reference error on line - var1 =
dl.SelectedValue.ToString
Can anyone point me in the right direction.
Many thanks
Have a bit of a problem..
I have a data list and in the item template I have an image button.
The Data list is data bound to sql data:
id
picId
etc...
The data key name for the data list = id
The imageUrl for the image button is bound to picId.
When the image button is clicked I need to get the selectedValue of the of
the item
here's what I've got:
Protected Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs) Handles
DataList1.ItemCommand
If e.CommandName = "test" Then
Dim var1 As String
Dim dl As New DataList
dl = Me.FindControl("DataList1")
var1 = dl.SelectedValue.ToString
End If
End Sub
All i'm getting is a null reference error on line - var1 =
dl.SelectedValue.ToString
Can anyone point me in the right direction.
Many thanks