.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

'<%# Eval("ID") %>

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

I want to get the "Id" according to the selected data in the GridView.

I tried something like this:
<Asp: LinkButton ID = "DeleteButton22" runat = "server" CommandName = "Delete" Text = 'test' CommandArgument ='<%# Eval ("ID")%> '/>

but does not work.

View Complete Post

More Related Resource Links

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

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

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

The result of an Eval



I've a question what needs to be fixed soon as possible (A)


I've made a page with data from my MS-SQLServer. The data in that db I want to show on the screen (an interger). I want to take that integer and * 2, by example:

74 * 2 = 148 -> show on the website.




SQL 2008 eval expired, ran maintenance Edition upgrade but still can't start services


We unknowingly installed a MSDN evaluation copy of SQL 2008 on a production server.  The evaluation period expired and we're no longer able to access the database.  We have purchased SQL 2008 and have run the Maintenence Edition Upgrade, it completed successfully but the SQL services will not start, event logs for the various SQL services reference 'evaluation period has expired'.  We have modified the CommonFiles DWORD value to 3 in the HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\100\ConfiguratioState key as noted in other posts and tried rerunning the the upgrade. We've also tried running the install on just the shared tools as referenced on another post, the install ran successfully but still not allowing the SQL services to start.

We don't want to lose our database if at all possible.  Any assistance is greatly appreciated.

Bind .NET ListVIew to Sharpoint list with Eval


I have a rather basic question of something that I just can't get to work. I have a user control with a ListView control. In the code-behind for the user control I bind the control to a SharePoint list.

Now, I want to render the items in a certain way in the LayoutTemplate and ItemTemplate sections of the ListView. I try to do this by binding to the columns with Eval, but this binding never returns any data work... 


This is some of the ascx:


<asp:ListView ID="ListView1" runat="server">
  <asp:PlaceHolder ID<

Can I do something like that in LinkButton: PostBackUrl="MyPage.aspx&id=" + '<%# Eval("Id") %>' ?


Can I add this two things and How or it may not possible?

asp:LinkButton ID="LinkButton1"

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