Last post Mar 30, 2005 05:51 AM by gotty101
Mar 29, 2005 10:12 AM|gotty101|LINK
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
<%# 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
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.
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.
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
Mar 29, 2005 10:30 AM|bmains|LINK
I don't see a DataItem property for System.Web.UI.MobileControls.TemplateContainer class...
Mar 30, 2005 05:51 AM|gotty101|LINK
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
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">
<mobile:Label ID="lblName" Runat="server"><%# DataBinder.Eval(((ObjectListItem)Container).DataItem,"Name") %></mobile:label>
Any help to solving this will be much
Mar 30, 2005 06:14 AM|gotty101|LINK
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") %>'>