DataBinder.Eval RRS feed

  • Question

  • User297738609 posted

    I recently built a standard web forms app, within I had datagrids with template columns. With in the template columns there where labels. A datatable was bound to the datagrid and was bound. The certain fields where then bound to the corresponding labels in the template column using the following code in the html

     <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    <%# DataBinder.Eval(Container.DataItem,"PurchaseCount") %>


    Today I came to write my first mobile web app. On the form I added a objectList control, I then right clicked and selected templating options and added the “default” group. As the markup schema “Mobile HTML 3.2 Template” was auto selected. Again a datatable was bound to the datagrid and was bound.   I then proceeded to build my template column using mobile labels, and in the html for the label

    <%# DataBinder.Eval(Container.DataItem,"PurchaseCount") %>


    When I tried to run the page I got the following error


    “Compiler Error Message: BC30456: 'DataItem' is not a member of 'System.Web.UI.MobileControls.TemplateContainer'.”   And the error pointed to the DataBinder.eval line in the html. <o:p></o:p>


    Does anyone know how to do this correctly? Or know of a weblink where I may find out how to acceve this. Ive tried the examples given by Microsoft at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mwsdk/html/mwcondatabindingviewingdatausingobjectlistcontrol.asp to the bottom of the page and I could not get any to work. <o:p></o:p>


    Any Ideas?<o:p></o:p>


    Im sure what im trying to do is posiable as once the server has built the page and sent it, all the client would be getting is lables within a table 



    Many Thanks<o:p></o:p>


    Tuesday, March 29, 2005 10:12 AM

All replies

  • User-294030300 posted

    I don't see a DataItem property for System.Web.UI.MobileControls.TemplateContainer class...

    Tuesday, March 29, 2005 10:30 AM
  • User297738609 posted

    Well ive been using google ect and still have had no luck.

    In the microsoft MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mwsdk/html/mwcondatabindingviewingdatausingobjectlistcontrol.asp) they say to databind like this :


    And in a post on another forum this method is said again http://www.dotnet247.com/247reference/msgs/19/97821.aspx

    But how come when i try this i get this error, if thats how microsoft say to do it

    BC30684: 'ObjectListItem' is a type and cannot be used as an expression.

    And the error points to the databind.eval line

     <mobile:ObjectList id="oblItems" runat="server" CommandStyle-StyleReference="subcommand" LabelStyle-StyleReference="title"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>


    <Choice Xmlns="http://schemas.microsoft.com/mobile/html32template"><o:p></o:p>


    <mobile:Label ID="lblName" Runat="server"><%# DataBinder.Eval(((ObjectListItem)Container).DataItem,"Name") %></mobile:label><o:p></o:p>






    Any help to solving this will be much appreciated <DEVICESPECIFIC><CHOICE Xmlns="http://schemas.microsoft.com/mobile/html32template"><ITEMTEMPLATE><%# DataBinder.Eval(((ObjectListItem)Container).DataItem,"Name") %></ITEMTEMPLATE></CHOICE></DEVICESPECIFIC>

    Wednesday, March 30, 2005 5:51 AM
  • User297738609 posted

    Ive just found another msdn artical and that said a different way, which sorted it [:D]. http://support.microsoft.com/kb/q309496/


       Text='<%# Ctype(Container, ObjectListItem)("fieldname") %>'>

    Wednesday, March 30, 2005 6:14 AM