473,397 Members | 2,077 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,397 software developers and data experts.

DataGrid - Template Columns

Hy Guys..

I have a datagrid with template columns. The datagrid have a datatable
datasource. But when I try to bind data, I receive this error:

DataBinder.Eval: 'System.Web.UI.WebControls.DataGridItem' do not have a
property named "Codigo".

See my code:

<asp:TemplateColumn HeaderText="Código">
<HeaderStyle HorizontalAlign="Justify" Width="80px"
CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Justify"></ItemStyle>
<ItemTemplate>
<asp:label ID="item_lblPediGrCo" Text=' <%#
DataBinder.Eval(Container, "Codigo") %>' Runat="server" Width='80px' />
</ItemTemplate>
<EditItemTemplate>
<asp:label ID="edit_lblPediGrCo" Text='' Runat="server" Width='80px'
/>
</EditItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Produto">
<HeaderStyle HorizontalAlign="Justify" Width="80px"
CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Justify"></ItemStyle>
<ItemTemplate>
<asp:label ID="item_lblPediGrPr" Text=' <%#
DataBinder.Eval(Container, "Produto") %>' Runat="server" Width='80px' />
</ItemTemplate>
<EditItemTemplate>
<asp:dropdownlist Width="80px" ID="edit_drpPediGrPr"
CssClass="Standard-text" DataSource='<%# drppediprod %>' Runat="server">
</asp:dropdownlist>
</EditItemTemplate>
</asp:TemplateColumn>
Where is the error????

Thank's
Nov 18 '05 #1
1 1113
André Almeida Maldonado wrote:
Hy Guys..

DataBinder.Eval: 'System.Web.UI.WebControls.DataGridItem' do not have a
property named "Codigo".

See my code:

<asp:TemplateColumn HeaderText="Código">
<HeaderStyle HorizontalAlign="Justify" Width="80px"
CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Justify"></ItemStyle>
<ItemTemplate>
<asp:label ID="item_lblPediGrCo" Text=' <%#
DataBinder.Eval(Container, "Codigo") %>' Runat="server" Width='80px' />
Where is the error????

Thank's


try
DataBinder.Eval(Container.DataItem, "Codigo")

instead of
DataBinder.Eval(Container, "Codigo")
the Container is the DataGrid itself, so you have to reference .DataItem
to get that item's data in the datasource....

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #2

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

Similar topics

4
by: | last post by:
I have a datagrid with a template column that has a hyperlink and a label. The hyperlink text is bound to Title from my dataset and the label text is bound to Author in the dataset. The grid...
4
by: Richard Roche | last post by:
Is it possible to use a drop combo instead of a text box when using the EditCommand in the Datagrid? Many table columns are bound to 'lookup' tables, user's don't care about the foreign keys,...
2
by: Nicole | last post by:
I am creating template columns programmatically. I have read the msdn article on this and I'm so close. Article:...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
4
by: Stephan Bour | last post by:
Hi, I have a datagrid databound to a SQL query. I'd like to allow editing of some columns but not all. Is there a way to turn off the conversion of the datagrid cells to textboxes for some columns...
2
by: CW | last post by:
In an earlier thread, I was asking for help on "Invalid attempt to FieldCount when reader is closed" error when I was using a dataset rather than a datareader to bind to a datagrid. After...
6
by: Khumar | last post by:
Hello, Im new in asp.net especially in web base application. I want to ask about datagrid. I had shown my table on datagrid, and what I want to ask is how to set the column height fixed?...
2
by: saleek | last post by:
Hi, I am trying to figure out why my datagrid has stopped firing the page and sort commands. Scenario: I originally had template columns in my datagrid and had set up custom bi-directional...
8
by: Matt | last post by:
Guys I could really use some help with this. I think that it's probably a simple solution but I haven't been able to find anything. I have a datagrid on my form that I populate via code like...
8
by: =?Utf-8?B?bWlrZWc=?= | last post by:
Hi, I am building a small Help Desk application for my company and need to be able to edit "open" help desk issues. I use a simple datagrid to display each issue (6 per page) , with an Edit...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.