I solved it!
I was looking for solution on web but didn't find it, so I will post it because it's a usual problem that is encountered.
Problem with ItemTemplate is, when you put Command control in it for details to show, then it will do postback and rebind items that are already binded when page was loaded.
Solution is to use Link command instead of Command.
Now, there are two ways that can be used, one using JavaScript, other to use anchor element.
I will show here anchor element because it's present on (X)HTML and WML so I think it will work on every mobile browser.
Solution is similar in the way that ASP.NET framework auto-generates.
Step by step:
1) Create in App_Code folder .cs file with this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.MobileControls;
using System.Web.UI;
namespace MyNamespace
{
public class DetailsLink : MobileControl
{
public DetailsLink()
{
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<a href=\"objectlist_test.aspx?__VIEWSTATE=" + Page.Server.UrlEncode(MobilePage.ClientViewState) +
"&__ET=myObjectList&__EA=" +
((ObjectListItem)this.NamingContainer).Index.ToString()
+ "&__ufps=" +
"\">" + "Show Details" + "</a>");
}
}
public class DetailsBackLink : MobileControl
{
public DetailsBackLink()
{
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<a href=\"objectlist_test.aspx?__VIEWSTATE=" + Page.Server.UrlEncode(MobilePage.ClientViewState) +
"&__ET=myObjectList&__EA=" +
"__back"
+ "&__ufps=" +
"\">" + "Back" + "</a>");
}
}
}
2) Register controls on page (or in web.config) so they can be used.
3) Put in ObjectList ItemTemplate DetailsLink control, and in ItemDetailsTemplate DetailsBackLink control.
4) In ObjectList.PreRender event put this code:
void myObjectList_PreRender(object sender, EventArgs e)
{
if (Request.Params.Get("__ET") == "myObjectList")
{
if (Request.Params.Get("__EA") == "__back")
{
myObjectList.ViewMode = ObjectListViewMode.List;
}
else
{
myObjectList.SelectedIndex = Int32.Parse(Request.Params.Get("__EA"));
myObjectList.ViewMode = ObjectListViewMode.Details;
}
}
}
That's it.
Solution is basic one, it can be extended, but basic code will be the same.