.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

DataBinder.Eval Vs DataBinder.GetPropertyValue

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :ASP.Net

Can anyone explain me that what is the diff between DataBinder.Eval Vs DataBinder.GetPropertyValue?

View Complete Post

More Related Resource Links

Format datetime in <%#DataBinder.Eval(Container.DataItem, "DBDate")%>

I have a date in a database which i bring into a repeater using <%#DataBinder.Eval(Container.DataItem, "DBDate")%>.  Can I format the datetime which is write to remove the time bit from it.  At the moment it is written in this format:25/02/2007 00:00:00. I want it to be 25/02/2007 or even a more readable date such as February 25th 2007. Thanks Andrew

Problem with System.Web.UI.DataBinder ??

Hi. I want to edit some fields in GridView so i wrote a code, but i need to use Eval() method and rowcommands so as i read in book i need to use ystem.Web.UI.DataBinder class which is part of System.Web.UI. I added but still got the problem:'ASP.default3_aspx' does not contain a definition for 'GridView7_RowDeleted' and no extension method 'GridView7_RowDeleted' accepting a first argument of type 'ASP.default3_aspx' could be found (are you missing a using directive or an assembly reference?)Here's my assemblies:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;

Extender Control with DataBinder Descriptor

Hi, I'm trying to create an Extender Control for a GridView.I followed the instructions in this document : http://msdn.microsoft.com/en-us/library/bb386403.aspx I need to set it a value (Binding) and then on it Postback action I want to retreived this value.Here is the Extender class[TargetControlType(typeof(Control))] public class MyExtender : ExtenderControl { private int _code; public int Code { get { return _code; } set { _code = value; } } protected override IEnumerable<ScriptReference> GetScriptReferences() { ScriptReference reference = new ScriptReference(); reference.Path = ResolveClientUrl("MyExtenderBehavior.js"); return new ScriptReference[] { reference }; } protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors(Control targetControl) { ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor("Samples.MyExtenderBehavior", targetControl.ClientID); descriptor.AddProperty("UniqueID", this.UniqueID); descriptor.AddProperty("code", this.Code); return new ScriptDescriptor[] { descriptor }; } void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) { ... // this._code is alway 0 !!! Not as the Databinder set Why ? } }The Behavior propertiesdoPos

Dynamic Object and Databinder

aHello,im trying to use dynamic object in a databinding tag , it gives me error that the property does not exists even though i can see all the properties there in the vs debug modehere is what im trying to do:C#:my method signature:public static dynamic MyMethod()ASPX:in control itemtemplate:<%# MyMethod().SomeProperty %>if also trite the other way:C#:public static object MyMethod()ASPX:<%# ((dymanic)MyMethod() ).SomeProperty%>But i dont know why it cant resolve the properties , even though i can see them when the databinder control throws an exception(its working fine outside the databinder tag (ie normal aspx tags <% %>)

CSS With Databinder And Left Trim


Hi there,

I've got a problem with the CSS layout for my website and the Container.DataItem nested inside a repeater.

I use a two column layout, and Databinder is in the left column.  When I use the trim, the right column goes under the left column and won't go over to the right column like it's supposed to.  The left column and right column both work fine with plain HTML.  I'm working on a blog for the website, so that's why I want the text trimmed.  Last night I thought I was going crazy and that my CSS skills needed brushing up.  Turns out it's a problem related to ASP.NET.  I'm a bit lost at this, so I'd appreciate if someone could point me in the right direction.  I'll post the code below.


html>body {
	margin: 0;
	padding: 0;

body {
	background-image: url(images/background.jpg);
	font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
	margin: 0;
	padding: 0;

#wrapper {
	background-image: url(images/wrapper.jpg);
	overflow: hidden;
	position: absolute; 
	/*height: 100%;*/
	/*min-height: 100%;*/
	width: 70%;
	margin-left: 200px;

#header {
	clear: both;

.logo {
	font-size: 40px;
	font-family: "Reprise Rehearsal";
	padding-top: 20px;

#LeftColumn {
	float: left;
	padding-left: 50p

Cutting Edge: Using an Eval Function in Web Services


Web Services are often presented as the perfect tool for pro-grammers. They're interoperable, based on open standards such as SOAP and WSDL, and are fully integrated with the Microsoft® . NET platform.

Dino Esposito

MSDN Magazine September 2002

Change fontsize dynamically with Eval

I am using a label which shows title of data rows in database, I want it to be font-resized since it is used in an table and I don't want the size of table to be extended. So I do want a good trick to resize the font by data length , here is what I did: <asp:Label ID="bipbip" runat ="server" Font-Size ='<%# if ( Eval("title").ToString.Length > 30 ) Then Small : Large %>'   Text =''><%#Eval("title").ToString.Length > 20%></asp:Label>It seems that if statement within Eval is different in behaviour because sometimes I get error saying that 'First operand in a binary 'If' expression must be nullable or a reference type.'How can I resize the label font size in this way.Also any other solution when I want to have fixed table size and not distorted or out of borders text?

Is it best to use Eval or Bind in a databound control?

I have a repeater I've databound with a generic arraylist from a LINQ query (.ToList() )  in the code behind.  I was using   <%# Bind("FirstName")%> but noticed  <%# Eval("FirstName")%> works just as well.    Is it better to use Eval or Bind?  or does it depend on the situation?        

onclick on control with eval dosn't work

Hi, I have an aspx control with works perfectly:<asp:HyperLink ID="lnkSeekJob" runat="server" Text="Søgt job" NavigateUrl='<%# "SeekJob.aspx?id=" + Eval("companyPId")%>' Target="SeekJob" name="SeekJob" onClick="wopen('SeekJob.aspx?id=3', 'popup', 600, 480); return false;" /> The problem is that the id isn't always 3 - so I have to get the rows id - I try this with eval:<asp:HyperLink ID="lnkSeekJob" runat="server" Text="Søgt job" NavigateUrl='<%# "SeekJob.aspx?id=" + Eval("companyPId")%>' Target="SeekJob" name="SeekJob" onClick='<%# "wopen('SeekJob.aspx?id=" + Eval("companyPId") + ", 'popup', 600, 480); return false;"%>' /> But I then get the error: The server tag isn't weel formed. I think (I'm pretty sure) it's because of the "/' . They aren't set correctly. Can anyone help me - so I set these correctly? Kind regards, simsen :-)

<%# eval> not working for a simple property

<form id="form1" runat="server"> <div> <table> <tr> <td>Name: <%#customer%> </td> </tr> </table> </div> </form>        Partial Class ScorePage Inherits System.Web.UI.Page Private _customer As String = "Sachin" Public Property customer() As String Get Return _customer End Get Set(ByVal value As String) _customer = value End Set End Property End Class   The expected result in html page is Name: Sachin But i am getting Name: property is not getting displayed. I thought instead of creating a label control, we can use this method, but it is not working  

EXPERT: avoiding weird refresh behavior of Eval method in a tabpanel

I have this control in a detailsview:<asp:DropDownList ID="ddlEventStartDay" SelectedValue='<%#Cdate(Eval("startdate")).Day %>' CssClass="textbox" runat="server">    <asp:ListItem Value="1" Text="01" />    <asp:ListItem Value="2" Text="02" />    <asp:ListItem Value="3" Text="03" />    <asp:ListItem Value="4" Text="04" />    <asp:ListItem Value="5" Text="05" />    <asp:ListItem Value="6" Text="06" />    <asp:ListItem Value="7" Text="07" />    <asp:ListItem Value="8" Text="08" />    <asp:ListItem Value="9" Text="09" />    <asp:ListItem Value="10" Text="10" />    <asp:ListItem Value="11" Text="11" />    <asp:ListItem Value="12" Text="12" />    <asp:ListItem Value="13" Text="13" />    <asp:ListItem Value="14" Text="14" />    <asp:ListItem Val

Finding underlying Eval or Bind column name from TemplateField

I need to be able to get the underlying column name from each TemplateField in my GridView. So I have something like:<asp:TemplateField HeaderText="Current Market Event" SortExpression="current_market_event"> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("current_market_event") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> I see how to do this with a BoundField quiet easily: BoundField.DataField. Is there any way to do this for a TemplateField?

custom DataControlField and <%# Eval('') %> problem



I have a custom DataControlField class that works fine but when I try to use  <%# Eval('???') %> with it I get an error.

"Databinding expressions are only supported on objects that have a DataBinding event. SharedGui.ImageLinkButtonField does not have a DataBinding event."

I can't get this to work, the DataControlField dosen't seem to have a DataBinding event to override or anything.

I could use a normal templatefield - itemtemplate etc. with eval but I don't want to rewrite this all the time.

Can this be solved in some way?

The class:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SharedGui
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public class ImageLinkButtonField : DataControlField
        #region Properties
        /// <summary> 
        /// The name of the DataField that will be bound 
        /// </summary> 
        public virtual string DataField
                object dataField = ViewState["DataField"];

Problem while upgrading from SQL 2008 Eval to SQL 2008 R2


Hi everyone, i'm trying to upgrade our SQL cluster from an Eval. version to a 2008R2 version.

During the setup i have this alert which makes the installation abort:

Cluster_FeatureDownGradeCheck Checks whether the edition of the selected SQL Server instance is supported in this SQL Server edtion downgrade scenario. Failed The edition of the selected SQL Server instance is not supported in this SQL Server edition downgrade scenario.


It's weird because we are not downgrading.... what should i check or fix?


Thank you!

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databou


within .aspx I have gridview I trying to hide link called Guide based on country.I am getting value of country from stored procedure.Once I get value of country I pass it to method called CountryConfigs which takes guidelink and countrycode as parameter.Based on parameter passed it will show and hide guide link.



Should I worry about the performance hit from Eval()?


I was reading the post http://forums.asp.net/p/1097781/2101105.aspx#2101105 while trying to figure out exactly what Eval() was. As it turned out it was just a short form of ((DataRowView)Container.DataItem)["String"] that I had already been using. Once I learned that I firgured I would just use Eval() since it would be less typing but then I read that Eval() uses  reflection so there would be a performance hit. Should I really be worried about the little bit of overhead that would be caused by using Eval() expecialy since I build my project before uploading to the server?

Gridview icw XMLDatasource :Databinding methods such as Eval(), XPath(), and Bind() can only be used


I want to get the value of an xpath expression in rowdatabound event. But I get:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

<asp:GridView ID="gvSearchResults"  AutoGenerateColumns="False" DataSourceID="XMLDS" runat="server">
    Rating:  <%# XPath("float[@name=""location_rating""]")%>

<asp:XmlDataSource EnableCaching="False" XPath="response/result/doc" ID="XMLDS" runat="server"></asp:XmlDataSource>

Protected Sub gvSearchResults_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvSearchResults.RowDataBound
    Dim value As String = XPath("float[@name=""location_rating""]")
End Sub

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend