Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.aspnet.mobile
ObjectList list view shows empty data when postback and rendering using item template
b301
10/27/2007 5:26:00 PM
Hi,
I have mobile form with objectlist.
I am using device specific rendering for ishtml32 devices using
templates.
It displays object list first time (when not postback) correct. When I
click on item, i am using default rendering for
itemdetail. Item detail shows fine.
Now when user clicks back link (default back button on item detail),
it comes back to objectlist list view,
but shows empty data in columns (item template/alt item template).
It works fine on device other than "ishml32", because it does not use
template rendering.
I am sure I am not the one who is going through this.
I would appreciate any help/suggestion.
Here is the test mobile form ObjectListWithTemplate.aspx I created
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="ObjectListWithTemplate.aspx.cs"
Inherits="mobile_ObjectListWithTemplate" %>
<%@ Import namespace="System.Web.UI.MobileControls"%>
<%@ Import namespace="System.ComponentModel"%>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile"
%>
<html xmlns="
http://www.w3.org/1999/xhtml...
<body>
<mobile:Form ID="Form1" Runat="server">
<mobile:ObjectList ID="ObjectList1" Runat="server"
CommandStyle-StyleReference="subcommand"
LabelStyle-StyleReference="title"
OnItemCommand="ObjectList1_ItemCommand">
<DeviceSpecific>
<Choice Filter="isHTML32">
<HeaderTemplate>
<table>
<tr>
<td>
Action
</td>
<td>
Col1Heading
</td>
<td>
Col2Heading
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr >
<td>
<mobile:Command ID="cmd1"
CommandName="View" Runat="server">Detail</mobile:Command>
</td>
<td>
<%#
DataBinder.Eval((ObjectListItem)Container, "DataItem.col1")%>
</td>
<td>
<%#
DataBinder.Eval((ObjectListItem)Container, "DataItem.col2")%>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr >
<td>
<mobile:Command ID="cmd1"
CommandName="View" Runat="server">Detail</mobile:Command>
</td>
<td>
<%#
DataBinder.Eval((ObjectListItem)Container, "DataItem.col1")%>
</td>
<td>
<%#
DataBinder.Eval((ObjectListItem)Container, "DataItem.col2")%>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList>
</mobile:Form>
</body>
</html>
Code behind:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class mobile_ObjectListWithTemplate :
System.Web.UI.MobileControls.MobilePage
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
ObjectList1.DataSource = getDataTable();
ObjectList1.DataBind();
ObjectList1.DataMember = "col1";
}
}
private DataTable getDataTable()
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("col1");
DataColumn dc1 = new DataColumn("col2");
DataColumn dc2 = new DataColumn("col3");
DataColumn dc3 = new DataColumn("col4");
dt.Columns.Add(dc);
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
DataRow dr = dt.NewRow();
dr["col1"] = "test1";
dr["col2"] = "mobile";
dr["col3"] = "Street 1";
dr["col4"] = "City1";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["col1"] = "Test2";
dr["col2"] = "aspnet";
dr["col3"] = "ghshxxx";
dr["col4"] = "City2";
dt.Rows.Add(dr);
return dt;
}
protected void ObjectList1_ItemCommand(object sender,
ObjectListCommandEventArgs e)
{
if(e.CommandName == "View")
{
ObjectList1.SelectedIndex = e.ListItem.Index;
ObjectList1.ViewMode = ObjectListViewMode.Details;
}
}
}
Thanks
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
ObjectList list view shows empty data when postback and rendering using item template
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password