.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

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

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net

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.



View Complete Post

More Related Resource Links

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

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?        

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?

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<

scriptcontrol eval methods to evaluate user expressions

I used to use the eval dot property of a script control in VB6 in order to evaluate a mathematical expression typed into a textbox by the client. Is there an equivalent method for Visual Basic 2008?

The Decorator Pattern & Extension Methods

The decorator pattern provides a formal way to add new functionality to an existing type, without sub-classing. First question: What is wrong with classical inheritance? In and of itself, nothing is wrong with the good old Is-A relationship. It is very common to derive a new class from an existing base class in order to override a few virtual members, and add a pinch of new functionality.

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

The Decorator Pattern & Extension Methods

Numerous design patterns exist in the software world today, and ultimately nothing is preventing you from making your own (if people buy into it or not is another question). Furthermore, there is no 'master list' of patterns that all developers agree upon. While this is true, if you pick up any book on the subject, you will find a set of very common patterns most programmers agree are very useful. Many of these patterns were first formalized in the seminal book on the subject, Design Patterns: Elements of Reusable Object-Oriented Software (aka, the Gang of Four [GOF] book; not to be confused with the UK punk band of the same name).

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

How to bind GridView and DropDownList controls using DataTable object

In .net framework 2.0, you can load a DataTable in memory by consuming a data source using a DataReader. In this version you will find the flexibility in accessing the DataReader means write access code once and use again and again using DataReader. To see the functionality of DataTable consider an example that is created using VS2005.

Xml File Methods and Properties

Method and Properties of XmlTextWriter class:
The XmlWriter class is a base class that outputs an XML data structure. It has methods to sequentially write XML elements in a proper hierarchy to create an XML file or other types of output streams. The System.Xml namespace provides support for the XmlWriter. It must be imported to the ASP.NET page with the directive

<%@ Import Namespace="System.Xml" %>

The XmlTextWriter

XmlWriter is an abstract class that is implemented as an extended XMLTextWriter class. The XmlTextWriter writes a sequence of XML nodes one element at a time. Output can be written to an XML file, although other streams of output data can be produced. It can create a new file or overwrite an existing file. Its non-cached writing techniques provides very fast generation of an output stream.

How to bind TemplateField DropDownList with ArrayList?


Hi Expert!

  I'm trying gridview templateField DropDownList bind with arraylist. When i set bindsource i got this error. "//Error Object reference not set to an instance of an object."

My Sample .aspx

<asp:TemplateField HeaderText="Type">
                        <asp:DropDownList ID="_grvcboType" runat="server" Width="117px" DataTextField="Display" DataValueField="Value">
                        <asp:Label ID="Label7" runat="ser

how to bind Dropdownlist based on textbox values



I have one drodownlist which show data based om textbox values...

Let us consider i have 

Select Name from table1 where Type IN(@typ)

here @typ is textbox values

here for example textbox will have some thing like this L1,L2,L3..

How to filter Name based and shown in drodownlist based on this L1,L2,L3(on textbox)..

Help me in this

xpath issue


Hi i am using xpath to loop through each node,

the xml is below i can get the value of "link" but i cant get the thumbnail value, have you got any ideas how i can do this, my code is below.



     <link>test 1</link>
     <media:thumbnail url="http://test.com/image.jpg" height="75" width="75" />



     <link>test 2</link>
     <media:thumbnail url="http://test.com/image.jpg" height="75" width="75" />


public void FindLinks(XPathNavigator p_xPathNav, DataTable dt)
            //run the XPath query
            XPathNodeIterator xPathIt = p_xPathNav.Select("//item");

            //use the

Page Methods and Yahoo UI


Hello people,
I'm constructing an application with Page Methods and YAHOO UI.
I'm Not using Update Panels because Page Methods are faster than Update Panel.

You can post your experiences with this feature of ASP.NET Extensions and vantages of using this type of architecture.

Thanks a lot.

Flávio Malaquias
Asp.Net Senior Developer

Multiple web methods in one transaction


Hi everyone

Sorry I am kinda new in web services, so it may sound a bit newbish question.

We have a web service that comunicates with the database and exposes web methods that enables the application to access the database. Each method does only one operation (Insert, Update or Delete). What I need to do is create a transaction that will be consisted of multiple calls to the database, meaning multiple calls of more then one web methods. Can I do that? (I read that if the web method does not throw exception - or ContextUtil.SetAbort() is not called - the transaction will be commited automatically when the web method finishes executing, which I don't want to happen because I want to call another web method in the same transaction, and then manually commit the transaction)

Thank you in advance.

Basic Instincts: Extension Methods


This column discusses one of the new features of Visual Basic 2008-Extension Methods. This powerful new feature was introduced to support LINQ. See what extension methods are, how to apply them yourself, and get some great usage tips.

Adrian Spotty Bowles

MSDN Magazine November 2007

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