473,386 Members | 1,712 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,386 software developers and data experts.

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 1668
Pierre:
Not sure I understand...

you have this:

<asp:label id="field" runat="server"> </asp:label> : <asp:textbox id="value"
runat="server" text='<%=DataBinder.Eval(Container.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*****@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.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='<%=DataBinder.Eval(Container.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*****@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.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.DataItem 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.DataRowView).DataView.Table.Columns(0) .ColumnName 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.microsoft.com> wrote in message
news:61**********************************@microsof t.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='<%=DataBinder.Eval(Container.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*****@discussions.microsoft.com> wrote in message news:3E**********************************@microsof t.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.DataItem 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.DataRowView).DataView.Table.Columns(0) .ColumnName 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.microsoft.com> wrote in message
news:61**********************************@microsof t.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='<%=DataBinder.Eval(Container.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*****@discussions.microsoft.com> wrote in message news:3E**********************************@microsof t.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
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: ...
0
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...
5
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...
3
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...
3
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 {...
10
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
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...
0
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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
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.