Help - Binding data on a UserControl within a DataGrid TemplateColumn

S

Stephen Barrett

I have an application that was originally built with ASP.Net 1.1.

We finally got permission to migrate to 2.0. Due to time constraints we
migrated the web projects to 2.0 web application projects to minimize
required changes initially.

I am stuck on a problem using a data grid.

I have a usercontrol that has a DataGrid on it. The datagrid has an item
template that loads another common user control for every row. I am getting
a binding error. Here is a snippet of the html for the datagrid.

<cc1:mymsgrid id="dgWebLeftNav" style="POSITION:relative" runat="server"
Width="100%" CellPadding="1" GridLines="None" AutoGenerateColumns="False"
DataSource="<%# m_dsWebLeftNav.Tables[0].DefaultView %>" ShowHeader="False">
<AlternatingItemStyle CssClass="ListItem1"></AlternatingItemStyle>
<SelectedItemStyle CssClass="DataGridSelectedItem"></SelectedItemStyle>
<ItemStyle CssClass="ListItem1"></ItemStyle>
<Behavior ShowSelection="False"></Behavior>
<HeaderStyle Height="1px" CssClass="DataGridHeader"
VerticalAlign="Middle"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<uc1:WebLeftNavItem id="WebLeftNavItem"
runat="server"></uc1:WebLeftNavItem>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</cc1:mymsgrid>

Here is a snippet of some of the child user control items with their
binding:
<DIV id="divWebLeftNavList" style="WIDTH: 100%; POSITION: relative; HEIGHT:
64px" runat="server">
<asp:label id=lblLefNavName style="Z-INDEX: 104; LEFT: 103px; POSITION:
absolute; TOP: 1px" CssClass="Body_Value9pt" runat="server" Width="290"
Text='<%# DataBinder.Eval(Container.BindingContainer,
"DataItem.WEB_LEFTNAV_NAME") %>'> </asp:label>
<asp:label id=lblLeftNavTitle style="Z-INDEX: 105; LEFT: 103px;
POSITION: absolute; TOP: 21px" CssClass="Body_Value9pt" runat="server"
Width="290px" Text='<%#
DataBinder.Eval(Container.BindingContainer,"DataItem.WEB_LEFTNAV_TITLE")
%>'></asp:label>
</DIV>

This was all working in Asp.net 1.1. The error I am getting is
"DataBinding: 'Aon.PenProPlus.Web.UI.WebControls.MyMSGrid' does not contain
a property with the name 'Item'." MyMSGrid is a descendent of the DataGrid
where we added a few extensions that we use not related to databinding.

I am guessing that Container.BindingContainer is returning a different
object that what asp.net 1.1 was returning.

Any help would be greatly appreciated.
 
S

Stephen Barrett

I typed the exception wrong. it should have been ....does not contain
a property with the name 'DataItem'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top