G
Guest
Let's say I have defined a class:
public class TestClass
{
int m_ID;
string m_UserTitle;
public TestClass(int ID, string UserTitle)
{
m_ID = ID;
m_UserTitle = UserTitle;
}
public int ID
{
get
{
return (m_ID);
}
}
public string UserTitle
{
get
{
return (m_UserTitle);
}
}
}
Now I want to display it using an ObjectList, so I do this on my ASPX page...
<mobile:ObjectList ID="OL" Runat="server"
CommandStyle-StyleReference="subcommand" AutoGenerateFields="False"
LabelStyle-StyleReference="title">
<DeviceSpecific>
<Choice>
<ItemDetailsTemplate>
<mobile:Label ID="Label4" Runat="server"><%# Eval("ID")
%></mobile:Label>
<mobile:Label ID="Label2" Runat="server"><%#
Eval("UserTitle") %></mobile:Label>
<mobile:Image ID="Image2" Runat="server"
ImageUrl="http://www.asp.net/App_Themes/Standard/i/logo.png"></mobile:Image>
</ItemDetailsTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList>
NOW, back in my page code, I do this...
private void DisplayList()
{
List<TestClass> L = new List<TestClass>();
L.Add(new TestClass(1, "UserTitle 1"));
L.Add(new TestClass(2, "UserTitle 2"));
OL.DataSource = L;
OL.DataBind(); //RUNTIME ERROR HAPPENS HERE!
}
Note that I am trying to configure this control to only have one template
which will be very VERY simple and should work for all devices.
When I have done all this, I get a runtime error on the DataBind() line as
follows...
System.Exception was unhandled by user code
Message="Must have one or more fields to databind.
(Application may have autogenerated fields from an empty DataSource. To
clear items, set DataSource to null.)"
Any ideas what I'm doign wrong here?
Thanks!
Alex
public class TestClass
{
int m_ID;
string m_UserTitle;
public TestClass(int ID, string UserTitle)
{
m_ID = ID;
m_UserTitle = UserTitle;
}
public int ID
{
get
{
return (m_ID);
}
}
public string UserTitle
{
get
{
return (m_UserTitle);
}
}
}
Now I want to display it using an ObjectList, so I do this on my ASPX page...
<mobile:ObjectList ID="OL" Runat="server"
CommandStyle-StyleReference="subcommand" AutoGenerateFields="False"
LabelStyle-StyleReference="title">
<DeviceSpecific>
<Choice>
<ItemDetailsTemplate>
<mobile:Label ID="Label4" Runat="server"><%# Eval("ID")
%></mobile:Label>
<mobile:Label ID="Label2" Runat="server"><%#
Eval("UserTitle") %></mobile:Label>
<mobile:Image ID="Image2" Runat="server"
ImageUrl="http://www.asp.net/App_Themes/Standard/i/logo.png"></mobile:Image>
</ItemDetailsTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList>
NOW, back in my page code, I do this...
private void DisplayList()
{
List<TestClass> L = new List<TestClass>();
L.Add(new TestClass(1, "UserTitle 1"));
L.Add(new TestClass(2, "UserTitle 2"));
OL.DataSource = L;
OL.DataBind(); //RUNTIME ERROR HAPPENS HERE!
}
Note that I am trying to configure this control to only have one template
which will be very VERY simple and should work for all devices.
When I have done all this, I get a runtime error on the DataBind() line as
follows...
System.Exception was unhandled by user code
Message="Must have one or more fields to databind.
(Application may have autogenerated fields from an empty DataSource. To
clear items, set DataSource to null.)"
Any ideas what I'm doign wrong here?
Thanks!
Alex