[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

ObjectList - Templated items/details problems

Brad

1/6/2003 11:32:00 PM

4 Answers

(Patrick C. Cole (MS))

1/7/2003 10:57:00 PM

0

Brad,

Let me research this further and I will post additional information. I
have a sample that uses two forms, not an ItemTemplate, in hopes this may
give you another avenue to accomplish something like this. Note that this
pulls information from the SQL Server Pubs database, but I think you should
be able to follow the logic of the sample.

I should be able to have a sample using the ItemTemplates tomorrow, 1/8/03.

MobileWebForm:

<mobile:form id="frmList" runat="server" PagerStyle-PreviousPageText="Back
to Page {0}" PagerStyle-NextPageText="Forward to Page {0}"
PagerStyle-Font-Bold="True" PagerStyle-Font-Size="Small" Paginate="True">
<mobile:Command id="cmdRefresh" runat="server">Refresh</mobile:Command>
<mobile:ObjectList id="oblProvider" runat="server"
AutoGenerateFields="false" CommandStyle-StyleReference="subcommand"
OnShowItemCommands="ShowVisit" LabelField="au_fname">
<Field Title="au_id" DataField="au_id"></Field>
<Field Title="au_fname" DataField="au_fname"></Field>
<Field Title="au_lname" DataField="au_lname"></Field>
</mobile:ObjectList>
<mobile:Link id="Link2" runat="server"
NavigateUrl="Home.aspx">Home</mobile:Link>
</mobile:form>
<mobile:form id="frmDetail" runat="server">
<mobile:Label id="lblHeader" runat="server" ForeColor="#0000C0"
Font-Bold="True" Font-Name="Courier New">Label</mobile:Label>
<mobile:Label id="Label1" runat="server"
BreakAfter="False">FirstName</mobile:Label>
<mobile:TextBox id="txtFName" runat="server"></mobile:TextBox>
<mobile:Label id="Label2" runat="server"
BreakAfter="False">LastName</mobile:Label>
<mobile:TextBox id="txtLName" runat="server"></mobile:TextBox>
<mobile:Label id="lblPatient" runat="server"
BreakAfter="False">Patient</mobile:Label>
<mobile:Command id="cmdUpdate" runat="server">Update</mobile:Command>
</mobile:form>

Code Behind:

Imports System.Data
Imports System.Data.SqlClient

Public Class MobileWebForm1
Inherits System.Web.UI.MobileControls.MobilePage
Protected WithEvents cmdRefresh As System.Web.UI.MobileControls.Command
Protected WithEvents oblProvider As
System.Web.UI.MobileControls.ObjectList
Protected WithEvents Link2 As System.Web.UI.MobileControls.Link
Protected WithEvents frmList As System.Web.UI.MobileControls.Form
Protected WithEvents frmDetail As System.Web.UI.MobileControls.Form
Protected WithEvents txtFName As System.Web.UI.MobileControls.TextBox
Protected WithEvents txtLName As System.Web.UI.MobileControls.TextBox
Protected WithEvents lblHeader As System.Web.UI.MobileControls.Label
Protected WithEvents Label1 As System.Web.UI.MobileControls.Label
Protected WithEvents Label2 As System.Web.UI.MobileControls.Label
Protected WithEvents cmdUpdate As System.Web.UI.MobileControls.Command
Protected WithEvents lblPatient As System.Web.UI.MobileControls.Label


#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
BindData()
End If
End Sub

Protected Sub BindData()
Dim myConnection As New SqlConnection("User
ID=username;password=password;Initial Catalog=pubs;Data Source=server")
Dim myCommand As New SqlDataAdapter("SELECT * FROM Authors",
myConnection)
Dim ds As New DataSet()
myCommand.Fill(ds, "authors")

oblProvider.TableFields = "au_id;au_fname;au_lname;"
oblProvider.DataSource = ds.Tables("authors")
oblProvider.DataBind()
End Sub

Public Sub ShowVisit(ByVal sender As Object, ByVal e As
System.Web.UI.MobileControls.ObjectListShowCommandsEventArgs)
lblHeader.Text = e.ListItem("au_lname")
Me.lblPatient.Text = e.ListItem("au_id")
Me.txtFName.Text = e.ListItem("au_fname")
Me.txtLName.Text = e.ListItem("au_lname")

If Session("parentSelectedItemIndex") = vbNull Then
Session.Add("parentSelectedItemIndex",
oblProvider.SelectedIndex)
Else
Session("parentSelectedItemIndex") = oblProvider.SelectedIndex
End If

Me.ActiveForm = frmDetail
End Sub

Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdUpdate.Click
Dim sql As String
Dim update As SqlCommand
sql = "UPDATE Authors SET au_lname = '" + txtLName.Text + "' WHERE
au_id = '" + lblPatient.Text + "'"
Dim myConnection As New SqlConnection("User
ID=sa;password=ncc1701b;Initial Catalog=pubs;Data Source=norrin")
update = New SqlCommand(sql, myConnection)
update.Connection.Open()
update.ExecuteNonQuery()
BindData()
Me.ActiveForm = frmList
End Sub

Private Sub frmList_Activate(ByVal sender As Object, ByVal e As
System.EventArgs) Handles frmList.Activate
oblProvider.SelectedIndex = CInt(Session("parentSelectedItemIndex"))
End Sub
End Class

Thanks!

Patrick Cole
Microsoft Developer Communities

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.
--------------------
| Reply-To: "Brad" <nospam@co.lane.or.us>
| From: "Brad" <nospam@co.lane.or.us>
| Subject: ObjectList - Templated items/details problems
| Date: Mon, 6 Jan 2003 14:32:37 -0800
| Lines: 339
| MIME-Version: 1.0
| Content-Type: multipart/alternative;
| boundary="----=_NextPart_000_0016_01C2B590.75E4EB50"
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <eCyojNdtCHA.2588@TK2MSFTNGP12>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.mobile
| NNTP-Posting-Host: risxlr5.ris.lane.or.us 199.79.46.126
| Path: cpmsftngxa09!TK2MSFTNGP08!TK2MSFTNGP12
| Xref: cpmsftngxa09 microsoft.public.dotnet.framework.aspnet.mobile:5339
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.mobile
|
| I have created an ObjectList with an ItemTemplate and an
ItemDetailTemplate. I seem to have the list and detail page displaying
correctly...however I'm getting errors when navigating from detail back to
the list,
| With databinding only on posting (Ispostback = false) I select my back
button on the detail page and the detail page just displays again (the
ItemCommand doesn't seem to fire. I press the details Back button again an
I get the following error when:
| Object reference not set to an instance of an object.
| If I databind on every page load the back button works the first time,
however I now get this error:
| Value cannot be null. Parameter name: child
| Here's some (abbreviated) code from my page. Am I missing something
subtle to get the Back working or is my page/code flawed in general?
| Thanks
| Brad
| ================================================
| ASPX Page code snip
| ================================================
| <mobile:ObjectList id="eventsList" runat="server" ItemsPerPage="4" >
| <DeviceSpecific>
| <Choice Filter="isHTML32"
Xmlns="http://schemas.microsoft.com/mobile/html32template...
| <ItemTemplate>
| <%# DisplayItem(Ctype(Container, ObjectListItem).DataItem)%>
| <mobile:Command Runat="server" CommandName="viewDetail"
CommandArgument="detail" Format="Link" ID="viewDetail"
EnableViewState="true">
| <%# DataBinder.Eval(Ctype(Ctype(Container,
ObjectListItem).DataItem, DataRowView), "Title") %>
| </mobile:Command>
| </ItemTemplate>
| <ItemDetailsTemplate>
| <%# DisplayDetail()%>
| <mobile:Command Runat="server" CommandName="viewList"
CommandArgument="list" Format="Link" ID="viewList" EnableViewState="true">
| Back...
| </mobile:Command>
| </ItemDetailsTemplate>
| =================================================
| Code Behind snip
| =================================================
| '*******************************
| ' Page Load
| '*******************************
| Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
| ' If Page.IsPostBack = False Then
| eventsList.DataSource = MySqlDataTable
| eventsList.DataBind
| ' End If
| End Sub
| '*******************************
| ' Display a list item - Called from ItemTemplate
| ' sender is objectlistitem's DataItem object
| '*******************************
| Public Function DisplayItem(ByVal sender As System.Object) As String
| Dim item As DataRow = DirectCast(sender, DataRowView).Row
| Dim html As New System.Text.StringBuilder()
| html.Append(String.Format("{0:ddd MMM %d}",
item(EventData.StartDtTm)))
| html.Append(String.Format(" {h:mm tt}",
item(EventData.StartDtTm)))
| html.Append(item(EventData.Title))
| Return html.ToString
| End Function
| '*******************************
| ' Display a detail item - Called from ItemDetailsTemplate
| ' Note diff from DisplayItem sub...This uses
objectlistitems.item(fields) to extract data to display
| '*******************************
| Public Function DisplayDetail() As String
| With eventsList.Items(eventsList.SelectedIndex)
| Dim html As New System.Text.StringBuilder()
| html.Append(String.Format("{0:dddd MMMM %d yyyy}",
.Item(EventData.StartDtTm)))
| html.Append(String.Format(" {0:h:mm tt} - {1:h:mm tt}",
.Item(EventData.StartDtTm), .Item(EventData.EndDtTm)))
| html.Append("<br>")
| html.Append(.Item(EventData.Title))
| html.Append("<br>")
| html.Append(.Item(EventData.Description))
| Return html.ToString
| End With
| End Function
| '*******************************
| ' Item command for show detail command
| ' and for back command on detail page
| '*******************************
| Private Sub eventsList_ItemCommand(ByVal sender As Object _
| , ByVal e As
System.Web.UI.MobileControls.ObjectListCommandEventArgs) _
| Handles eventsList.ItemCommand
| If e.CommandName = "viewDetail" Then
| eventsList.SelectedIndex = e.ListItem.Index
| eventsList.ViewMode =
MobileControls.ObjectListViewMode.Details
| Else
| eventsList.ViewMode = MobileControls.ObjectListViewMode.List
| End If
| End Sub
|

Brad

1/8/2003 10:20:00 PM

0

Thanks, Patrick
Yes, I had made a working version that uses two mobile forms on the page,
one for the object list and the other for the detail item. This works just
fine but I wanted to levergae the objectlist items/detail more....thus the
question I posed. I look forward to your example.
Regards
Brad

"Patrick C. Cole [MSFT]" <patcole@online.microsoft.com> wrote in message
news:Ltb5GfptCHA.2372@cpmsftngxa09...
| Brad,
|
| Let me research this further and I will post additional information. I
| have a sample that uses two forms, not an ItemTemplate, in hopes this may
| give you another avenue to accomplish something like this. Note that this
| pulls information from the SQL Server Pubs database, but I think you
should
| be able to follow the logic of the sample.
|


(Patrick C. Cole (MS))

1/9/2003 9:17:00 PM

0

Brad,

I am having some success with this, I have at least gotten the Back command
to actually return the List into the correct mode. But I am still working
on getting this completed. I will send you the sample as soon as I have
worked through further.

Patrick Cole
Microsoft Developer Communities

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.
--------------------
| Reply-To: "Brad" <nospam@co.lane.or.us>
| From: "Brad" <nospam@co.lane.or.us>
| References: <eCyojNdtCHA.2588@TK2MSFTNGP12>
<Ltb5GfptCHA.2372@cpmsftngxa09>
| Subject: Re: ObjectList - Templated items/details problems
| Date: Wed, 8 Jan 2003 13:20:30 -0800
| Lines: 21
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <uR8ngu1tCHA.2620@TK2MSFTNGP11>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.mobile
| NNTP-Posting-Host: risxlr5.ris.lane.or.us 199.79.46.126
| Path: cpmsftngxa09!TK2MSFTNGP08!TK2MSFTNGP11
| Xref: cpmsftngxa09 microsoft.public.dotnet.framework.aspnet.mobile:5350
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.mobile
|
| Thanks, Patrick
| Yes, I had made a working version that uses two mobile forms on the page,
| one for the object list and the other for the detail item. This works just
| fine but I wanted to levergae the objectlist items/detail more....thus the
| question I posed. I look forward to your example.
| Regards
| Brad
|
| "Patrick C. Cole [MSFT]" <patcole@online.microsoft.com> wrote in message
| news:Ltb5GfptCHA.2372@cpmsftngxa09...
| | Brad,
| |
| | Let me research this further and I will post additional information. I
| | have a sample that uses two forms, not an ItemTemplate, in hopes this
may
| | give you another avenue to accomplish something like this. Note that
this
| | pulls information from the SQL Server Pubs database, but I think you
| should
| | be able to follow the logic of the sample.
| |
|
|
|

(Patrick C. Cole (MS))

1/16/2003 9:21:00 PM

0

Brad,

I apologize for the delay in posts. I have been working on this issue and
have some good news and bad news.

From my testing, using the ObjectsList in this manner will not work
correctly in the current version of the framework. The workaround is as I
posted before, using two forms and setting the ActiveForm to the necessary
form, either the Items or the Details.

The good news is that I have checked against the upcoming 1.1 release and
at this time it appears to be resolved. Certainly this may change before
the final release of the next version, but I wanted to let you know that
you should be able to use the Item/Detail views as you would like to in the
near future.

Please let me know if you have any questions about this issue.

Thanks!

Patrick Cole
Microsoft Developer Communities

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.
--------------------
| X-Tomcat-ID: 563073684
| References: <eCyojNdtCHA.2588@TK2MSFTNGP12>
<Ltb5GfptCHA.2372@cpmsftngxa09> <uR8ngu1tCHA.2620@TK2MSFTNGP11>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: patcole@online.microsoft.com (Patrick C. Cole [MSFT])
| Organization: Microsoft
| Date: Thu, 09 Jan 2003 20:17:52 GMT
| Subject: Re: ObjectList - Templated items/details problems
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.mobile
| Message-ID: <swdEpwBuCHA.1340@cpmsftngxa09>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.mobile
| Lines: 54
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
| Path: cpmsftngxa06!cpmsftngxa10!cpmsftngxa09
| Xref: cpmsftngxa06 microsoft.public.dotnet.framework.aspnet.mobile:5098
|
| Brad,
|
| I am having some success with this, I have at least gotten the Back
command
| to actually return the List into the correct mode. But I am still
working
| on getting this completed. I will send you the sample as soon as I have
| worked through further.
|
| Patrick Cole
| Microsoft Developer Communities
|
| This posting is provided "AS IS" with no warranties, and confers no
rights.
| You assume all risk for your use. © 2002 Microsoft Corporation. All
rights
| reserved.
| --------------------
| | Reply-To: "Brad" <nospam@co.lane.or.us>
| | From: "Brad" <nospam@co.lane.or.us>
| | References: <eCyojNdtCHA.2588@TK2MSFTNGP12>
| <Ltb5GfptCHA.2372@cpmsftngxa09>
| | Subject: Re: ObjectList - Templated items/details problems
| | Date: Wed, 8 Jan 2003 13:20:30 -0800
| | Lines: 21
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| | Message-ID: <uR8ngu1tCHA.2620@TK2MSFTNGP11>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.mobile
| | NNTP-Posting-Host: risxlr5.ris.lane.or.us 199.79.46.126
| | Path: cpmsftngxa09!TK2MSFTNGP08!TK2MSFTNGP11
| | Xref: cpmsftngxa09 microsoft.public.dotnet.framework.aspnet.mobile:5350
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.mobile
| |
| | Thanks, Patrick
| | Yes, I had made a working version that uses two mobile forms on the
page,
| | one for the object list and the other for the detail item. This works
just
| | fine but I wanted to levergae the objectlist items/detail more....thus
the
| | question I posed. I look forward to your example.
| | Regards
| | Brad
| |
| | "Patrick C. Cole [MSFT]" <patcole@online.microsoft.com> wrote in message
| | news:Ltb5GfptCHA.2372@cpmsftngxa09...
| | | Brad,
| | |
| | | Let me research this further and I will post additional information.
I
| | | have a sample that uses two forms, not an ItemTemplate, in hopes this
| may
| | | give you another avenue to accomplish something like this. Note that
| this
| | | pulls information from the SQL Server Pubs database, but I think you
| | should
| | | be able to follow the logic of the sample.
| | |
| |
| |
| |
|
|