Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Mobile > ObjectList list view shows empty data when postback and rendering using item template

Reply
Thread Tools

ObjectList list view shows empty data when postback and rendering using item template

 
 
b301
Guest
Posts: n/a
 
      10-27-2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using callback, I fill dorpdownlist without postback but it gets empty when a postback is executed Fabio Mastria ASP .Net 5 01-30-2008 09:07 PM
ObjectList Rendering Problems in Windows Mobile 5 Versions andrew.cripps@provident.co.uk ASP .Net Mobile 1 10-18-2006 06:26 AM
Combine @item.foo.nil? || @item.foo.empty? ? Joe Ruby Ruby 8 09-11-2006 09:58 PM
Can we use Data Grid in Item Template of Data List Control Shahid Saleem ASP .Net 1 08-26-2005 01:28 PM
First page empty on ObjectList Jonah Olsson ASP .Net Mobile 1 09-28-2004 07:33 PM



Advertisments