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

databinder.eval in code behind


Hi,

I would like to evaluate a field in a datagrids data source (that is not
bound to a column in the grid) in code behind rather that using inline
code Databinder.Eval(container.dataItem,"MyField"). I don't seem to be
able to use "container" in code behind, Would appreciate if someone
could explain how this statement would look within the ItemdataBound
event.

Thanks

Niclas
*** Sent via Developersdex http://www.developersdex.com ***
Dec 5 '05 #1
2 12867
Hi,

If you don't have to use DataBinder.Eval then don't because it involves
reflection. Anyways, what you look for is probably something like

Dim myField As String = DataBinder.Eval(e.Item.DataItem,"MyField")

Container in a databinding expression refers to the DataGridItem. so
therefor replacing Container.DataItem with e.Item.DataItem (e being the e in
event arguments for ItemDataBound)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"Niclas" <NO****@Notmail.com> wrote in message
news:eV***************@tk2msftngp13.phx.gbl...

Hi,

I would like to evaluate a field in a datagrids data source (that is not
bound to a column in the grid) in code behind rather that using inline
code Databinder.Eval(container.dataItem,"MyField"). I don't seem to be
able to use "container" in code behind, Would appreciate if someone
could explain how this statement would look within the ItemdataBound
event.

Thanks

Niclas
*** Sent via Developersdex http://www.developersdex.com ***

Dec 5 '05 #2
try e.Item.DataItem

or simply cast e.Item.DataItem to the underlying source, like DataRowView

DataRowView dr = (DataRowView) e.Item.DataItem;
dr["myColumn"];

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Niclas" <NO****@Notmail.com> wrote in message
news:eV***************@tk2msftngp13.phx.gbl...

Hi,

I would like to evaluate a field in a datagrids data source (that is not
bound to a column in the grid) in code behind rather that using inline
code Databinder.Eval(container.dataItem,"MyField"). I don't seem to be
able to use "container" in code behind, Would appreciate if someone
could explain how this statement would look within the ItemdataBound
event.

Thanks

Niclas
*** Sent via Developersdex http://www.developersdex.com ***

Dec 5 '05 #3

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

Similar topics

1
by: Mike Lerch | last post by:
Pretty much, TSIA, but I'll expand a bit: I'm still trying to get my head around the n-tier approach to web design. It seems to me that when you use DataBinder.Eval in the ASPX that your tiers...
3
by: Thubaiti | last post by:
Hi, I have this code in my ASP.NET and I want to convert it to C# (code behind) <asp:Repeater id="subCategoryRepeater" runat="server"> <ItemTemplate> <ul> <li> <asp:HyperLink...
6
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp;...
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...
11
by: eddy de boer | last post by:
Hello, in my aspx page I have the followong code: <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> .... <%# Server.HtmlDecode((string)DataBinder.Eval(Container.DataItem,"tekst"))...
8
by: Randall Parker | last post by:
I want to generate an HTML tag that will look like: <a href="EquipmentServiceCreate.aspx?serial=X01">Create New Service For X01</a> or on a different instance where the user would be viewing...
4
by: CharlesA | last post by:
a general question... I'm a bit mystified by Databinder.eval(object, Colname, ) if controls can be bound to their individual data sources within the load event of the page... why would we ever...
2
by: mikepolitowski | last post by:
Hi folks, I am have been trying to solve this problem for quite some time now and would appreciate any advice. I have been trying to call a code-behind function that is defined in my aspx.cs...
8
by: arsende | last post by:
I am creating a repater column programmatically, I can' t do with loops, please help me! <% foreach (string strTest in getRepeaterItemColumnName()) { %> <%#...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.