473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help - Binding data on a UserControl within a DataGrid TemplateColumn

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,"DataIt em.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.
Apr 23 '07 #1
1 2416
I typed the exception wrong. it should have been ....does not contain
a property with the name 'DataItem'

"Stephen Barrett" <stephen_barrett@aon_nospam.comwrote in message
news:uk**************@TK2MSFTNGP06.phx.gbl...
>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,"DataIt em.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.

Apr 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rmorvay | last post by:
I am trying to dynamically build a dropdownlist and bind it to a cell in a grid. I tried to utilize the following code but I am stuck at the point where I bind the dropdownlist to the grid cell. ...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
2
by: News | last post by:
Hi I need help to display and edit data in a data grid within a repeater. The code is below: Sub dgrdEvents_EditCommand(sender As Object, e As DataGridCommandEventArgs)...
1
by: Kasey Rybic | last post by:
I am trying to put data from a field of a query in to the HeaderText arg and I keep getting an error. <asp:DataGrid id="dgMainCompany" runat="server" width="55%" HorizontalAlign="Left"...
1
by: Roy | last post by:
I have a datagrid, within that datagrid I have <columns> tag and within that I have the below TemplateColumn which calls to another datagrid (essentially and embedded datagrid within another...
6
by: Alan Silver | last post by:
Hello, I am data binding a repeater that has a checkbox in the ItemTemplate. The data value coming out of the database is a char(1) field containing either "y" or "n". I want to use this value...
1
by: momo | last post by:
Hello Guys, I am getting this error " Control 'oGrid__ctl14__ctl1' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server." Here is my code and I don't know where...
2
by: momo | last post by:
Hello Guys, I have a bit of a problem, I created a Dll called SecureQueryStringDll.dll and I had the dll put bin folder of my application first and it did not work so I then put it in the bin...
0
by: Chu | last post by:
I've got a DataGrid that is bound at run-time to an ArrayList. In my DataGrid, I've created a <asp:templatecolumn> that and am using a custom web control in it, something like this: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.