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

Discussion in 'ASP .Net Mobile' started by b301, Oct 27, 2007.

  1. b301

    b301 Guest

    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
    b301, Oct 27, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gce
    Replies:
    0
    Views:
    766
  2. dancer

    CHECKBOX LIST ITEM SHOWS TWICE

    dancer, May 18, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    512
    Alexey Smirnov
    May 19, 2007
  3. Jonah Olsson

    First page empty on ObjectList

    Jonah Olsson, Sep 2, 2004, in forum: ASP .Net Mobile
    Replies:
    1
    Views:
    145
  4. Replies:
    1
    Views:
    707
  5. Gianni

    IE shows false and Firefox shows true

    Gianni, Jul 10, 2009, in forum: Javascript
    Replies:
    3
    Views:
    449
    Thomas 'PointedEars' Lahn
    Jul 10, 2009
Loading...

Share This Page