473,320 Members | 1,802 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 C# Question

If have i a funtion below:-
Protected Function CheckUnit(Units As Object) As String

'-----------------------------------------
' If the Units returned equals to Zero,
' a message of "Out of Units" will be displayed.
' Otherwise, displayed the original value
'-----------------------------------------

If Integer.Parse(Units) = 0 Then
Return "Out Of Units"
Else
Return Units.ToString()
End If

End Function

I use :- <%# CheckUnit(Container.DataItem("Units")) %>
to display the value of the function.
But in C sharp it gives error so i used

<%# DataBinder.Eval(Container.DataItem, "Units") %>
and it works!!

whats the right code when using C# to dislpay the value using

<%# DataBinder.Eval(Container.DataItem, "Units") %>
with the CheckUnit Function???

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
2 5403
What is the error that occurred?

Try changing your CheckUnits to a public method.

bill

"Patrick Olurotimi Ige" <ig*@iprimus.com.au> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
If have i a funtion below:-
Protected Function CheckUnit(Units As Object) As String

'-----------------------------------------
' If the Units returned equals to Zero,
' a message of "Out of Units" will be displayed.
' Otherwise, displayed the original value
'-----------------------------------------

If Integer.Parse(Units) = 0 Then
Return "Out Of Units"
Else
Return Units.ToString()
End If

End Function

I use :- <%# CheckUnit(Container.DataItem("Units")) %>
to display the value of the function.
But in C sharp it gives error so i used

<%# DataBinder.Eval(Container.DataItem, "Units") %>
and it works!!

whats the right code when using C# to dislpay the value using

<%# DataBinder.Eval(Container.DataItem, "Units") %>
with the CheckUnit Function???

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #2
DataBinder.Eval also returns a string, so you might change your method
signature.

bill

"Patrick Olurotimi Ige" <ig*@iprimus.com.au> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
If have i a funtion below:-
Protected Function CheckUnit(Units As Object) As String

'-----------------------------------------
' If the Units returned equals to Zero,
' a message of "Out of Units" will be displayed.
' Otherwise, displayed the original value
'-----------------------------------------

If Integer.Parse(Units) = 0 Then
Return "Out Of Units"
Else
Return Units.ToString()
End If

End Function

I use :- <%# CheckUnit(Container.DataItem("Units")) %>
to display the value of the function.
But in C sharp it gives error so i used

<%# DataBinder.Eval(Container.DataItem, "Units") %>
and it works!!

whats the right code when using C# to dislpay the value using

<%# DataBinder.Eval(Container.DataItem, "Units") %>
with the CheckUnit Function???

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #3

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

Similar topics

0
by: Michelle Keys | last post by:
Subject: DataBinder.Eval Error! Server Error in '/MSPOS' Application. ------------------------------------------------------------------------ -------- DataBinder.Eval:...
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: ...
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...
1
by: Chris | last post by:
Hey Okay using DataBinder.Eval in a repeater. My question is this - if the value is empy, eg the myDownloadFile is empty, how can i display different output than if it was populated. #...
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: 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 {...
3
by: Mark Jones | last post by:
I am quite new to ASP and .Net development and I am building a web-based multiple choice exam application. The web page displays the questions using a Repeater control and the answers are nested...
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...
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...
14
by: WT | last post by:
Hello, I have a usercontrol loaded in a page with a theme. This usercontrol contains columns template with hyperlinks, with skinID. The columns are not displayed, seems thta there is some...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...

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.