473,805 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Dat aGridItem' do not have a
property named "Codigo".

See my code:

<asp:TemplateCo lumn HeaderText="Cód igo">
<HeaderStyle HorizontalAlign ="Justify" Width="80px"
CssClass="grid-header" VerticalAlign=" Middle"></HeaderStyle>
<ItemStyle HorizontalAlign ="Justify"></ItemStyle>
<ItemTemplate >
<asp:label ID="item_lblPed iGrCo" Text=' <%#
DataBinder.Eval (Container, "Codigo") %>' Runat="server" Width='80px' />
</ItemTemplate>
<EditItemTempla te>
<asp:label ID="edit_lblPed iGrCo" Text='' Runat="server" Width='80px'
/>
</EditItemTemplat e>
</asp:TemplateCol umn>

<asp:TemplateCo lumn HeaderText="Pro duto">
<HeaderStyle HorizontalAlign ="Justify" Width="80px"
CssClass="grid-header" VerticalAlign=" Middle"></HeaderStyle>
<ItemStyle HorizontalAlign ="Justify"></ItemStyle>
<ItemTemplate >
<asp:label ID="item_lblPed iGrPr" Text=' <%#
DataBinder.Eval (Container, "Produto") %>' Runat="server" Width='80px' />
</ItemTemplate>
<EditItemTempla te>
<asp:dropdownli st Width="80px" ID="edit_drpPed iGrPr"
CssClass="Stand ard-text" DataSource='<%# drppediprod %>' Runat="server">
</asp:dropdownlis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
Where is the error????

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

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

See my code:

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

Thank's


try
DataBinder.Eval (Container.Data Item, "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
5408
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 displays with the template columns showing the Title and the Author from the first row in all rows. The other none template columns are fine. Obviously I am not understanding something here. What am I missing????? -- Barry Fitzgerald
4
5981
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, they want the text value. Any advice, samples or places to read are appreciated. Thanks.
2
4554
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchcreatingwebservercontroltemplatesprogrammatically.asp I have narrowed down the problem comes in when the _DataBinding handler is called and the literal text is being assigned, but I can't figure out beyond that. The main problem is that...
3
4889
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 the best method? Do you have a sample of how to do this?
4
1799
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 when the Edit button is pressed? Thank you, Stephan.
2
1532
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 playing around with it, I found out that the error was caused by template columns. Once I remove template columns, everything worked fine. Here are my scenarios and I would appreciate input on it. My datagrid is bound to a orderlines table. In the...
6
1845
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? Because when I have a long word it automatically set new line instead of hide it. I want it to be hide like this 928192... with 3 dot at the end of the word if it is to long.
2
3151
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 sorting as well as paging of the datagrid records.
8
3898
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 this... Me.My_DataGrid.Rows.Add(Column1, Column2, Column3) Well now I have a datagrid that I want to populate with an image. So for example...
8
1997
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 button. There are a lot of fields across, and my Network Admins would like a way of editing/updating each issue seperately in a a vertical form. I need a way of clicking on the edit button ,bringing up a form with the record, editng the fields, and...
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10368
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.