'TextBox' cannot have children of type 'DataBoundLiteralControl'.
Mar 13
2006
From what I've seen this particular error is already pretty well documented, however it is one of the things that Visual Studio is a little misleading about.
Seems this is a lesson why you can't always rely on intellisense to tell you what to type. In a datagrid, the following code will error:
Error:
<EDITITEMTEMPLATE> <asp:TextBox id=TextBox1 runat="server"> <%# TimeZoneInformation.ToLocalShortDateString(
(DateTime)DataBinder.Eval(Container.DataItem, "FromDate")) %>
</asp:TextBox> </EDITITEMTEMPLATE>
This will land you with a "'TextBox' cannot have children of type 'DataBoundLiteralControl'." error.
Solution.
<EDITITEMTEMPLATE>
<asp:TextBox id="TextBox1" runat="server"
value='<%# TimeZoneInformation.ToLocalShortDateString( (DateTime)DataBinder.Eval(Container.DataItem, "FromDate")) %>'> </asp:TextBox> </EditItemTemplate>
In this case the "value" tag is valid, even though intellisense doesn't think so.
No new comments are allowed on this post.

Comments
Chris E
You have no idea how grateful I am for this little gem of help, thank you!
- Chris from Cheshire, UK, currently building an estate agents website in VS.net.
Said
Thanks Man ..that saved me lot of headache
Ramesh
Thanks it was helpfull
Leo
Great! I'm always trying to find such a solution. Thank you!
Kelvin
Without this little tip, i could have spent the last few hours trying to figure out how to get my datagrid to work. Nice one, brotha!
Ian C
Thanks, just what I was after. intellisense lets us down again.
jovan blanco
this tip is so helpful!, thanks!
Mattoir
I can only echo what has already been said, without this i would've been hunting round for ages and then writing lots of innefficient code. Cheers!
RAVI
Thank You Very Much
I am Happy
RAVI
Doru Pirvu
Great!
God Bless You!
vishakha
Thanks a lot.