sample:
<asp:GridView ID="StudentMarksGridView" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="MP1">
<HeaderTemplate>
<asp:Label ID="StudentMarks_Mark_Header_1" runat="server"
Text='<%# MarkBucketTitleShort(1) %>'></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:UpdatePanel UpdateMode="Conditional"
ID="StudentMarks_Mark_1_UP" runat="server">
<ContentTemplate >
<asp:TextBox ID="StudentMarks_Mark_1_DDL"
Visible='<%# not
DataBinder.Eval(Container.DataItem, "StudentMarks.IsDroppedSection" %>'
Enabled='<%# not
DataBinder.Eval(Container.DataItem, "StudentMarks.IsDroppedSection" %>'
AutoPostBack="true"
MaxLength="3"
CssClass="MarksUpdateMarkItemDDL"
runat="server"
Text='<%#
DataBinder.Eval(Container.DataItem, "StudentMarks.Mark_1_D" %>'>
</asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
The gridview is programmatically bound to a list whose items have the above
referenced properties. The above gives the BC030456 error.
If the UpdatePanel is removed then it works fine.
If the above is changed to reference a function that is passed the container
it also works as follows:
<asp:GridView ID="StudentMarksGridView" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="MP1">
<HeaderTemplate>
<asp:Label ID="StudentMarks_Mark_Header_1" runat="server"
Text='<%# MarkBucketTitleShort(1) %>'></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:UpdatePanel UpdateMode="Conditional"
ID="StudentMarks_Mark_1_UP" runat="server">
<ContentTemplate >
<asp:TextBox ID="StudentMarks_Mark_1_DDL"
Visible='<%# not
IsDroppedSection(Container) %>'
Enabled='<%# not
IsDroppedSection(Container) %>'
AutoPostBack="true"
MaxLength="3"
CssClass="MarksUpdateMarkItemDDL"
runat="server"
Text='<%# Mark(Container, 1) %>'>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
Code:
Public Function IsDroppedSection(ByVal ContainerControl As Control) As
Boolean
Return CType(CType(ContainerControl, GridViewRow).DataItem,
SectionStudentItem).StudentMarks.IsDroppedSection
End Function
Public Function Mark(ByVal ContainerControl As Control, ByVal Index As
Int16) As String
Return CType(CType(ContainerControl, GridViewRow).DataItem,
SectionStudentItem).StudentMarks.Mark(Index)
End Function
Any comment?
Thank you!
--
Robert Pfeffer
Student Management Services,LLC.
I suggest you use "<%# Eval( "field" ) %>" instead of "<%#
DataBinder.Eval(Container.DataItem, "field") %>" in this scenario.
Container.DataItem is a runtime alias for the DataItem for this specific
item in the bound list.The actual type of DataItem is determined by the
type of the datasource.In this scenario, I think the type of the datasource
cause the issue.
DataBinder.Eval() is the helper method that figures out the syntax for you
and formats the result as a string. It's really convenient, and it's late
bound.
Please check this link about it:
http://weblogs.asp.net/rajbk/archive/2004/07/20/what-s-the-deal-with-databin
der-eval-and-container-dataitem.aspx
Sincerely,
Vince Xu
Microsoft Online Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
--------------------
| Thread-Topic: BC30456: 'DataItem' is not a member of
'System.Web.UI.Control ...
| thread-index: AcodFXq3TjOYLMVXTji36/ZY5mpamw==
| X-WBNR-Posting-Host: 69.112.87.170
| From: =?Utf-8?B?Um9iZXJ0IFBmZWZmZXI=?= <r...@community.nospam>
| Subject: BC30456: 'DataItem' is not a member of 'System.Web.UI.Control ...
| Date: Fri, 14 Aug 2009 12:29:02 -0700
| Lines: 95
| Message-ID: <D8981ED0-DE02-4C9B...@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4325
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:938
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol