473,664 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about DataBinder.Eval method

I have a form with a DataList control with a label control and a text control
in the ItemTemplate section. I can display the data in the text contol using
the DataBinder.Eval method and I also want to display the Field or the Column
title in the Label control.

How can I retrieve the column (field) name from the Container?

TIA
Nov 19 '05 #1
4 1684
Pierre:
Not sure I understand...

you have this:

<asp:label id="field" runat="server"> </asp:label> : <asp:textbox id="value"
runat="server" text='<%=DataBi nder.Eval(Conta iner.DataItem, "FirstName" )%>'
/>

From what I understand you want to display "FirstName" in the label...why
not simply type in "FirstName" ...clearly you know what the column name is
because you are using it in the text control....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Pierre Shirvan" <Pierre Sh*****@discuss ions.microsoft. com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
I have a form with a DataList control with a label control and a text control in the ItemTemplate section. I can display the data in the text contol using the DataBinder.Eval method and I also want to display the Field or the Column title in the Label control.

How can I retrieve the column (field) name from the Container?

TIA

Nov 19 '05 #2
Karl:
I wanted to change the label's text dynamically from code. Does the DataItem
has a property that holds the field name?

Pierre

"Karl Seguin" wrote:
Pierre:
Not sure I understand...

you have this:

<asp:label id="field" runat="server"> </asp:label> : <asp:textbox id="value"
runat="server" text='<%=DataBi nder.Eval(Conta iner.DataItem, "FirstName" )%>'
/>

From what I understand you want to display "FirstName" in the label...why
not simply type in "FirstName" ...clearly you know what the column name is
because you are using it in the text control....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Pierre Shirvan" <Pierre Sh*****@discuss ions.microsoft. com> wrote in message
news:3E******** *************** ***********@mic rosoft.com...
I have a form with a DataList control with a label control and a text

control
in the ItemTemplate section. I can display the data in the text contol

using
the DataBinder.Eval method and I also want to display the Field or the

Column
title in the Label control.

How can I retrieve the column (field) name from the Container?

TIA


Nov 19 '05 #3
Pierre,
Yes and no...if you are binding to a DataSet, DataTable or DataView,
Container.DataI tem is actually of type DataRowView, from which you can get
the underlying DataTable. The DataTable does indeed know the column names,
but not sure how you figure out which column you want.

ctype(Container .DataItem,
System.Data.Dat aRowView).DataV iew.Table.Colum ns(0).ColumnNam e but not
sure how you figure out that you want column 0

That's all I can think of...
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Pierre Shirvan" <Pi***********@ discussions.mic rosoft.com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
Karl:
I wanted to change the label's text dynamically from code. Does the DataItem has a property that holds the field name?

Pierre

"Karl Seguin" wrote:
Pierre:
Not sure I understand...

you have this:

<asp:label id="field" runat="server"> </asp:label> : <asp:textbox id="value" runat="server" text='<%=DataBi nder.Eval(Conta iner.DataItem, "FirstName" )%>' />

From what I understand you want to display "FirstName" in the label...why not simply type in "FirstName" ...clearly you know what the column name is because you are using it in the text control....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Pierre Shirvan" <Pierre Sh*****@discuss ions.microsoft. com> wrote in message news:3E******** *************** ***********@mic rosoft.com...
I have a form with a DataList control with a label control and a text

control
in the ItemTemplate section. I can display the data in the text contol

using
the DataBinder.Eval method and I also want to display the Field or the

Column
title in the Label control.

How can I retrieve the column (field) name from the Container?

TIA


Nov 19 '05 #4
Karl:

Good question Regarding knowing which field to choose. The data comes from a
stored procedure and I could select the fields in proper order and use the
column index to address the columns.

the info on ItemData was very useful.
Thank you

Pierre

"Karl Seguin" wrote:
Pierre,
Yes and no...if you are binding to a DataSet, DataTable or DataView,
Container.DataI tem is actually of type DataRowView, from which you can get
the underlying DataTable. The DataTable does indeed know the column names,
but not sure how you figure out which column you want.

ctype(Container .DataItem,
System.Data.Dat aRowView).DataV iew.Table.Colum ns(0).ColumnNam e but not
sure how you figure out that you want column 0

That's all I can think of...
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Pierre Shirvan" <Pi***********@ discussions.mic rosoft.com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
Karl:
I wanted to change the label's text dynamically from code. Does the

DataItem
has a property that holds the field name?

Pierre

"Karl Seguin" wrote:
Pierre:
Not sure I understand...

you have this:

<asp:label id="field" runat="server"> </asp:label> : <asp:textbox id="value" runat="server" text='<%=DataBi nder.Eval(Conta iner.DataItem, "FirstName" )%>' />

From what I understand you want to display "FirstName" in the label...why not simply type in "FirstName" ...clearly you know what the column name is because you are using it in the text control....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Pierre Shirvan" <Pierre Sh*****@discuss ions.microsoft. com> wrote in message news:3E******** *************** ***********@mic rosoft.com...
> I have a form with a DataList control with a label control and a text
control
> in the ItemTemplate section. I can display the data in the text contol
using
> the DataBinder.Eval method and I also want to display the Field or the
Column
> title in the Label control.
>
> How can I retrieve the column (field) name from the Container?
>
> TIA


Nov 19 '05 #5

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

Similar topics

2
2039
by: dm_dal | last post by:
I have a control on my webform that I am binding to a dataset. The issue is, the field value in the dataset is encrypted and I am trying to decrypt it during the binding process: Example: <asp:Lable ID="myLable Text='<%# myComponent.Decrypt(DataBinder.Eval(myDataSet, "Tables.DefaultView..MyField")) '></asp:Label>
0
993
by: Logan McKinley | last post by:
I have a datalist that takes two clicks to show the SelectedItem or UpdateItem. The first click seems to fire the event but does not seem to change the page, the second click doesn't fire the event but changes the page. I have noticed people don't bind the data on post back but when i used if(!Page.IsPostBack) to only bind the date on the first load it seems to loose everything but the date of things that have been displayed with...
5
724
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash (DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name date) <asp:DataGrid id="RssNewsGrid"
3
1628
by: Leo | last post by:
I have a datagrid with the first column as a Edit,Update,Cancel button column. The other 5 columns are template columns. When I click the Edit button in IE6 the row correctly displays the controls defined in the <EditItemTemplate> however when I right click and do a view source I cannot find any of the input textboxes in the source. I have used the ItemDatabound event to try to attach javascript to the textboxes and in debug mode while...
3
2261
by: Eric Newton | last post by:
Given databinding an array of System.Version types: Given that "SomeObject" type has a Version property: public class SomeObject { public Version Version { get; } public string Description { get; } }
10
3974
by: Patrick Olurotimi Ige | last post by:
I have a checkbox and i want to input Char "Y" or "N" to the Table In C# we could use for example :- ptrTest.Value = chkYN.Checked ? "Y" : "N"; Whats the equivalent in VB.NET?
2
11163
by: Oleg Ogurok | last post by:
Hi all, I have a DatePicker ASP.NET control that allows users to enter date (e.g. a calendar control). The control has the following property public DateTime Value { get; set; } I've placed the control into a datagrid now I'm trying to bind values from database to the datagrid.
0
282
by: erin.sebastian | last post by:
Hello All, I have created a web page. At the top of the page there are 4 links; upon clicking on one of the links it brings up the left hand side menu, it's a repeater that loops through items selected from the database based on the id of the link chosen from the link at the top of the page. The page that displays the information is the same page for each menu item as the details are stored in the database and selected based on the id...
3
3394
by: Kevin Blount | last post by:
In a DataList, I'm using the following: <%# DataBinder.Eval(Container.DataItem, "characterization")%> I was wondering if it's possible to create a string that would contain the value of the above line, so that I can manipulate it: I tried string resultText = DataBinder.Eval(Container.DataItem, "characterization");
0
8437
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
8778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8636
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
7375
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...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
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
4185
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2764
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.