Here is an example from code that I wrote:
Private Sub datResults_Item DataBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data ListItemEventAr gs) Handles
datResults.Item DataBound
If e.Item.ItemType = ListItemType.It em AndAlso
CType(e.Item.Fi ndControl("lblR egion1"), Label).Text = "*NONE*" Then
CType(e.Item.Fi ndControl("lblR egion1"), Label).Text = " "
End If
If e.Item.ItemType = ListItemType.Al ternatingItem AndAlso
CType(e.Item.Fi ndControl("lblR egion2"), Label).Text = "*NONE*" Then
CType(e.Item.Fi ndControl("lblR egion2"), Label).Text = " "
End If
If e.Item.ItemType = ListItemType.It em AndAlso
CType(e.Item.Fi ndControl("lblP hone1"), Label).Text = "" Then
CType(e.Item.Fi ndControl("lblP hone1"), Label).Text = " "
If e.Item.ItemType = ListItemType.Al ternatingItem AndAlso
CType(e.Item.Fi ndControl("lblP hone2"), Label).Text = "" Then
CType(e.Item.Fi ndControl("lblP hone2"), Label).Text = " "
End Sub
Notice that at the end of the first line it refers to the event as
datResults.Item DataBound (this is the standard objectID.eventn ame format).
As for your question about referencing a textbox (or any other Control used
in your Template), you must use
CType(e.Item.Fi ndControl(contr olID),ControlTy pe) to reference the Control.
This is necessary because since there are many Items in a DataList (for
example, my example will include many controls with the ID lblPhone1), you
cannot simply use just the ID. All my sample code is in VB.NET, if you have
any questions let me know.
--
Nathan Sokalski
nj********@hotm ail.com http://www.nathansokalski.com/
"MasterChie f" <co*******@mi x-net.net> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
I can't seem to find the ItemDataBound event. I can find it for the
gridview but not the formview which is where the insert template I am
using is. I am trying to use the databinding event is that the same
thing as ItemDataBound? Also how do I reference the textbox in the form
view? Like I can't see to go plan_startdateT extBox.text =
DateTime.Today. ToString()
Protected Sub plan_startdateT extBox_DataBind ing(ByVal sender As
Object, ByVal e As System.EventArg s)
End Sub