Jim,
You can only use databinding syntax within a databound control (repeater,
datalist, datagrid, dropdownlist, ...). From the error, it seems that you
have a free flowing texbox with no parent control.
For example, instead of having:
<asp:repeater id="repeater" runat="Server">
<itemtemplate>
<asp:textbox id="date" runat="Server" Text='<%#
DataBinder.Eval(Container.DataItem, "EventStartDate", "{0:d}")%>' />
</itemtemplate>
</asp:repeater>
and binding the repeater to a datasource, you simply have:
<asp:textbox id="date" runat="Server" Text='<%#
DataBinder.Eval(Container.DataItem, "EventStartDate", "{0:d}")%>' />
Understanding what's going on is important, so let's look at this line:
DataBinder.Eval(Container.DataItem, "EventStartDate", "{0:d}")
DataBinder.Eval -->
This is simply a helper object which let's you do late-binding...basically
it figures out what Container.DataItem is and how to get "EventStartDate"
out of it and into your specified format
Container.DataItem -->
This is saying get the Container (which in the first example is the repeater
row)'s dataitem. This is where you are going wrong.
I'd like to see more code and html to get a context for what you are trying
to do.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jim Heavey" <Ji*******@discussions.microsoft.com> wrote in message
news:FC**********************************@microsof t.com...
I'm trying to figure out what is wrong with this statement...
Text='<%# DataBinder.Eval(Container.DataItem, "EventStartDate",
"{0:d}")%>'
This is in a textbox. I'm using the exact format of this statement as a
stand along value (not embedded in an ASP control), but when I place it
into the Textbox control, I get an error as follows: 'System.Web.UI.Control'
does not contain a definition for 'DataItem'.
The format within my control looks OK to me, here is the code for the
entire control
<asp:TextBox ID="txtEditEventStartDate" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "EventStartDate",
"{0:d}")%>'></asp:TextBox><br>
But There must be something wrong that I do not see.