'System.Web.UI.WebControls.DataListItem.DataItem' is a 'property' but is used like a 'method'

 HI I have a datalist with OnItemDataBound

I get the following error when I try to get the DataItem

'System.Web.UI.WebControls.DataListItem.DataItem' is a 'property' but is used like a 'method' , any idea what's wrong with the line ?


public void Item_Bound(object sender, DataListItemEventArgs e)

        Label originalPriceLabel;
        if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem)
            originalPriceLabel = ((Label)(e.Item.FindControl("originalPriceLabel")));
            decimal result = Convert.ToDecimal(e.Item.DataItem("originalPrice"));
            if (result < 1)
                originalPriceLabel.Visible = false;
                originalPriceLabel.Visible = true;

5/5/2007 11:17:34 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 46
Get it on Google Play
Get it on Apple App Store

Use square brackets rather than round when using a string as an index.
5/5/2007 11:51:57 PM

When I use square brackets I get a different error message


CS0021: Cannot apply indexing with [] to an expression of type 'object'

5/5/2007 11:58:50 PM


You can try this syntax:

DataBinder.Eval( e.Item.DataItem,"originalPrice");
I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance

Best Regards,
Rex Lin
Microsoft Online Community Support

If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
5/8/2007 3:39:23 AM
Yes it works fine now. Thanks
5/8/2007 9:04:31 AM

Similar Artilces:

'System.Web.UI.IDataItemContainer.DataItem' is a 'property' but is used like a 'method'
On the line "<%# Container.DataItem("BlogID") %>", I get the error listed in the title of this post. I'm not sure why, I use this same for on other pages to get data from a database and I don't get this error.         <asp:GridView ID="GridView1"         runat="server"         AutoGenerateColumns="False"         DataKeyNames="BlogID"        D...

Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/ GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

CS0118: 'System.Web.UI.WebControls.DataGridItem.DataItem' denotes a 'property' where a 'method' was expected
Hai .....,            In my datagrid, I would to display information using this ItemTemplate tag. But when i execute my page, I get the following error:CS0118: 'System.Web.UI.WebControls.DataGridItem.DataItem' denotes a 'property' where a 'method' was expected            In VB.NET, it is working perfectly but in C# it's not. I know to display data using DataBinder.Eval(Container.DataItem, "Field"), but would like Container.DataItem("Field") to work. Regards,HemantThanx and Regar...

Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

'System.Web.HttpContext.Session' is a 'property' but is used like a 'method
Hello, I'm trying to set my sessions into a class so I can set and access it easily. I get a 'System.Web.HttpContext.Session' is a 'property' but is used like a 'method' error, can you see what's wrong with my code ?  Thanks  public class SessionManager    {                public static bool isLogged        {            get        &nb...

Can any one help due to this problem Error 1 'System.Web.UI.Page.Application' is a 'property' but is used like a 'method'
Hi all ! while creating application,session variables i am getting this problem can u suggest any one. Error 1 'System.Web.UI.Page.Application' is a 'property' but is used like a 'method'  lokesh   As a general guideline for seeking help, always show the code that is not working for you.  Your description alone is not enough for us to be able to help you. Alister kplokesh: Hi all ! while creating application,session variables i am getting this problem can u suggest any one. Error 1 'System.Web.UI.Page.Application' is a 'property' but is us...

System.Web.UI.Page.Cache is a 'property' but is used like a 'method'
if (Cache("MyData") == null){ds = myclasslibrary.lookupIDs();  <<filling datasetif (ds != null){if (ds.Tables[0].Rows.Count > 0){ddl.DataTextField = "Text";ddl.DataValueField = "ID";ddl.DataSource = ds;ddl.DataBind();Cache.Insert("MyData", ds, null,DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration);} }else{ds = ((DataSet) (Cache("MyData")));} error: System.Web.UI.Page.Cache is a 'property' but is used like a 'method'Its all about coding! Change the 2 lines that say Cache("MyData") to be Cache["MyData"] instead.If this post answered your question please remember to ...

'System.Web.UI.Control.Context' denotes a 'property' where a 'class' was expected
I get the following error when trying to compile my project. The call to Context lies in a usercontrol. It works fine when called from a page, but how do I call it from a usercontrol? private User _currentUser = new User(Context.User.Identity.Name); 'System.Web.UI.Control.Context' denotes a 'property' where a 'class' was expected Firefox - The browser you can trust Update: private User _currentUser = new User(Context.User.Identity.Name);Is declared inside the class, not in a function. Like: public class Someclass : System.Web.UI.UserControl { private User _currentUser = new...

System.Data.DataSet.Tables' is a 'property' but is used like a 'method'?
     private void PassID(string x)    {        //string strConnection = System.Configuration.ConfigurationManager.ConnectionStrings("FasR6ConnectionString").ConnectionString;        string strConnection = System.Configuration.ConfigurationManager.AppSettings["FasR6ConnectionString"].ToString();         SqlConnection objConnection = new SqlConnection(strConnection);        string query = "spGetEm...

is a 'property' but is used like a 'method'
Hi forum, I need some help! Ive converted a script from VB to C#. Come across the:  is a 'property' but is used like a 'method' CS0118 error. Ive searched about,  I should use [] not (). Im just not sure exactly where on this line of code, much thanks P  if ((Request("capability") != null) && (Request("userAgent") != null))   if (Request["capability"] != null && Request["userAgent"] != null)Encosia - ASP.NET, AJAX, and more.Latest article: Using complex types to make calling servic...

'DataItem' is not a member of 'System.Web.UI.Control'
I was going through the "WEb Matrix Guided Tour" and ran across the following error when I tried to do the section "ASP.NET Pages with Data (SQL Server/MSDE) DataList and Templates". I went through it three times and can not get past this point. Any suggestions would be appreciated. PS: Rookie to this, so please be kind!!! Server Error in '/' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this requ...

Error: Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField'
Hello, I am getting the following error during compiliation. Any suggestions to fix it. Thanks. Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField' protected void gvEvents_RowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gvEvents.Rows[index]; string sID; ButtonField btn; if (selectedRow.RowType == DataControlRowType.DataRow) { sID = ((ButtonField)selectedRow.FindControl("ID")).DataTextFi...

'DataItem' is not a member of 'System.Web.UI.Control'
Hi I am getting this error on my attempt at a repeater control. Any help would be appreciated. This is the code for the HTML <asp:Repeater id="rptTests" runat="server"></asp:Repeater> <ITEMTEMPLATE> <tr style="BACKGROUND-COLOR: #ffecd8"> <td> <%# DataBinder.Eval(Container.DataItem, "test") %> </td> </tr> </ITEMTEMPLATE> This is the cod...

'do' won't 'do' if '/'
Greetings to All from Au, Have a NetWare Perl 5.8.4 and wanted to tweak File\Spec\NW.pm to try and standardise on '/' separators. If I run a test script (t/uni/lower.t) with an unmodified NW.pm, it calls t/uni/case.pl, that, in case.pl, (when the path separators are '\'), the $file is '..\lib\unicore\To\Lower.pl' and the following code portion works, with $simple getting a returned table: sub casetest { my ($base, $spec, $func) = @_; my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", &qu...

Web resources about - 'System.Web.UI.WebControls.DataListItem.DataItem' is a 'property' but is used like a 'method' - asp.net.presentation-controls

Resources last updated: 1/18/2016 3:36:32 AM