Jim in Arizona wrote:
How do I find a control within a datalist itemtemplate from a sub
procedure that isn't a normal called procedure from a datalist (like the
update, edit, or cancel procedures)?
For instance, normally you find a control and access it's properties and
methods, like so:
Sub Update(ByVal sender As Object, ByVal e As DataListCommandEventArgs)
Dim txtPosted As New TextBox
txtPosted = e.Item.FindControl("txtPosted")
End Sub
How could I do this using a different procedure, like:
Sub AnotherProcedure()
End Sub
TIA,
Jim
After some experimentation and trying to follow examples at this location:
http://quickstarts.asp.net/QuickStar.../datalist.aspx
I have come up this this code:
Sub HideOrShowButton()
Dim i As Integer
Dim lblDate As New Label
Dim btnUpdate As New Button
For i = 0 To dlNotes.Items.Count - 1
lblDate = dlNotes.Items(i).FindControl("lblDate")
btnUpdate = dlNotes.Items(i).FindControl("btnUpdate")
If lblDate.Text = "1/4/2007 10:15:00 AM" Then
btnUpdate.Visible = True
Else
btnUpdate.Visible = False
End If
Next
End Sub
This is unrefined, but is a good start to what I'm hoping for. My goal
is to make visible or invisible a button based on the original post time
of the db record.
If anyone can think of a better way of doing this that's not overly
complicated, please post!
Thanks to those who replied.