473,508 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the Value of a field bound to a Repeater

Hello all..
I have what is probably a simple question but I can't find the answer for it
yet.

I have a Repeater bound to a Datatable.

In the OnItemDataBound event controller in the Code Behind I am trying to
pull a value from one of the DataSource fields that is not bound to a
control that is part of the repeater. If it was bound to a label control,
for example I could just do e.Item.FindControl("lblCost").text, to get that
value.

I see an e.Item.DataItem referenced in the Docs and my first impulse was to
try something simple like,
varValue = e.Item.DataItem("fieldname"). value, but that doesn't work.

Can I reference the bound Datasource here somehow?

Or is it as simple as varValue = Eval("fieldname") as it is done in the HTML
page?

Thanks for your answers....
Apr 19 '07 #1
3 10966
You are along the right lines...

The way I do it is:

object DI = e.Item.DataItem;

string MyVal = DataBinder.Eval(DI, "FieldName").ToString();

I don't know how efficient this is, but it works for me. Thinking more about
it, you might be able to do...

string MyVal = DataBinder.Eval(e.Item.DataItem, "FieldName").ToString();

though I have never tried it.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"John Kotuby" <jo***@powerlist.comwrote in message
news:OO*************@TK2MSFTNGP05.phx.gbl...
Hello all..
I have what is probably a simple question but I can't find the answer for
it yet.

I have a Repeater bound to a Datatable.

In the OnItemDataBound event controller in the Code Behind I am trying to
pull a value from one of the DataSource fields that is not bound to a
control that is part of the repeater. If it was bound to a label control,
for example I could just do e.Item.FindControl("lblCost").text, to get
that value.

I see an e.Item.DataItem referenced in the Docs and my first impulse was
to try something simple like,
varValue = e.Item.DataItem("fieldname"). value, but that doesn't work.

Can I reference the bound Datasource here somehow?

Or is it as simple as varValue = Eval("fieldname") as it is done in the
HTML page?

Thanks for your answers....


Apr 19 '07 #2
if your repeater is bound to a datatable then the dataitem will be a
DataRow. you just need to cast it to use it.

string value = ((DataRow)e.Item.DataItem)["fieldname"].ToString();
-- bruce (sqlwork.com)

John Kotuby wrote:
Hello all..
I have what is probably a simple question but I can't find the answer for it
yet.

I have a Repeater bound to a Datatable.

In the OnItemDataBound event controller in the Code Behind I am trying to
pull a value from one of the DataSource fields that is not bound to a
control that is part of the repeater. If it was bound to a label control,
for example I could just do e.Item.FindControl("lblCost").text, to get that
value.

I see an e.Item.DataItem referenced in the Docs and my first impulse was to
try something simple like,
varValue = e.Item.DataItem("fieldname"). value, but that doesn't work.

Can I reference the bound Datasource here somehow?

Or is it as simple as varValue = Eval("fieldname") as it is done in the HTML
page?

Thanks for your answers....

Apr 19 '07 #3
Thank you for your answers gentlemen,

Both syntax formats seem to work.
I appreciate the help.

"John Kotuby" <jo***@powerlist.comwrote in message
news:OO*************@TK2MSFTNGP05.phx.gbl...
Hello all..
I have what is probably a simple question but I can't find the answer for
it yet.

I have a Repeater bound to a Datatable.

In the OnItemDataBound event controller in the Code Behind I am trying to
pull a value from one of the DataSource fields that is not bound to a
control that is part of the repeater. If it was bound to a label control,
for example I could just do e.Item.FindControl("lblCost").text, to get
that value.

I see an e.Item.DataItem referenced in the Docs and my first impulse was
to try something simple like,
varValue = e.Item.DataItem("fieldname"). value, but that doesn't work.

Can I reference the bound Datasource here somehow?

Or is it as simple as varValue = Eval("fieldname") as it is done in the
HTML page?

Thanks for your answers....


Apr 19 '07 #4

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

Similar topics

5
2277
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
1
3250
by: Sam | last post by:
Hi, I don't know how to specify the display and value field for a combobox when using AddRange to fill the combo. Here is what I have so far: -A function to build an array of object : Dim...
1
1559
by: arulbenito | last post by:
i need to write a xml data inside the value field in web.config file. it looks likes this <configuration> <appSettings> <add key="MyXmlData" value="<data><type></type>........." />...
1
1423
by: somanyusernamesaretakenal | last post by:
Hi everyone, I am working with Access 2003. I know a crosstab query only allows 1 value field, but how to do you around this restriction? I have a table with let’s say customers, products,...
10
1780
by: Hugh Middity2 | last post by:
Hello, is there a parameter value field in access that can be passed between queries, forms and reports? For example, we have two companies both selling the same products. To extract data we have to...
0
1507
by: dit | last post by:
Hello, I found this piece of code for selecting a dropDownlist value in a repeater: <aspropDownList id=ddl DataSource="<%# SourceTable %>" runat="server" DataTextField="Name"...
1
1220
by: renatois | last post by:
Getting value from GridView Hi guys, I have a GridView and I need to access a value of an ID field on an event. I converted this field into template and the name of the label control in...
15
4924
by: amy1 | last post by:
Hello everyone, I'm new here and new to Access2007 as well! I have a multi-value field in a form, and would like to calculate the total of the selected values in this field and place the...
19
7147
by: jaad | last post by:
how do you reference a single value field to a multi-value field? I sometime use a macro in form1 to open form 2 containing the same ID example: Open form: WorkOrder where condition: ="="...
0
7231
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
7132
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
7401
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...
0
7504
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...
1
5059
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...
0
3211
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...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.