Answered by:
ObjectList and ItemDetailsTemplate

Question
-
User1577742094 posted
My ItemDetailsTemplate (in addition to the item details) also has three radio buttons (SelectionListControl) and two command controls. It is my understanding that selecting items in a SelectionList mobile control does not generate a response from the server. I am, however, doing a post back with a command control and at that time I need to determine whether or not the radio buttons have been selected, but I'm receiving the following error: "Object reference not set to an instance of an object". Any advise regarding how to access properties for my radio buttons when I post back to the server with a command control? Code is displayed below.
1 Protected Sub Notice_OnItemCommand(ByVal sender As System.Object, ByVal e As System.Web.UI.MobileControls.ObjectListCommandEventArgs) Handles NoticeList1.ItemCommand
2
3 If (e.CommandName = "details") Then
4 NoticeList1.SelectedIndex = e.ListItem.Index
5 NoticeList1.ViewMode = ObjectListViewMode.Details
6 ElseIf (e.CommandName = "Acknowledge") Then
7 error ==> If (AckCallList.Items(0).Selected) Then
8 some code here....
9 End If
10 .
11 .
12 .
13 End Sub
14
15
16 <mobile:Form ID="Form1" runat="server">
17 <mobile:ObjectList ID="NoticeList1" Runat="server" Alignment="Left" CommandStyle-StyleReference="subcommand"
18 OnItemCommand="Notice_OnItemCommand" LabelField="PageID" AutoGenerateFields="False" LabelStyle-StyleReference="title">
19 <DeviceSpecific>
20 <Choice Xmlns="http://schemas.microsoft.com/mobile/html32template">
21 <HeaderTemplate>
22 <Table id="noticeTbl" cellspacing="5" cellpadding="5" width=300 border="0">
23 <tr>
24 <td colspan="3"><mobile:Label id="Label1" runat="server" Text="Unacknowledged Notices" Alignment="Center" BreakAfter="True"></mobile:Label></td>
25 </tr>
26 <tr>
27 <td><mobile:Label id="Label2" runat="server" Text="PageID" Alignment="Left" BreakAfter="False"></mobile:Label></td>
28 <td><mobile:Label id="Label3" runat="server" Text="Date/Time" Alignment="Center" BreakAfter="False"></mobile:Label></td>
29 <td><mobile:Label id="Label4" runat="server" Text="SourceID" Alignment="Right" BreakAfter="True"></mobile:Label></td>
30 </tr>
31 </Table>
32 </HeaderTemplate>
33 <ItemTemplate>
34 <Table id="noticeTbl" cellspacing="5" cellpadding="5" width=300" border="0">
35 <tr>
36 <td><asp:linkbutton id="lbnTask" commandname="details" runat="server">
37 <%# Ctype(Container, ObjectListItem)("PageID") %></asp:linkbutton></td>
38 <td><mobile:Label id="Label5" runat="server" Alignment="Center" Text='<%# Ctype(Container, ObjectListItem)("NoticeDtTm") %>' BreakAfter="false"></mobile:Label></td>
39 <td><mobile:Label id="Label6" runat="server" Alignment="Right" Text='<%# Ctype(Container, ObjectListItem)("SourceID") %>' BreakAfter="True"></mobile:Label></td>
40 </tr>
41 </Table>
42 </ItemTemplate>
43 <ItemDetailsTemplate>
44 <mobile:Panel ID="noticePanel" Runat="server">
45 <Table id="noticeTbl" cellspacing="5" cellpadding="5" width=300 border="0">
46 <tr>
47 <td colspan="3"><mobile:Label id="Label7" runat="server" Text="Notice Details" Alignment="Center" BreakAfter="True"></mobile:Label></td>
48 </tr>
49 <tr>
50 <td><mobile:Label ID="Label8" Runat="server" Text="PageID :" BreakAfter="False"></mobile:Label></td>
51 <td width="20"> </td>
52 <td><mobile:Label id="Label9" runat="server" BreakAfter="true" Font-Bold="True" Text='<%# Ctype(Container, ObjectListItem)("PageID") %>'></mobile:Label></td>
53 </tr>
54 <tr>
55 <td><mobile:Label ID="Label10" Runat="server" Text="SourceID:" BreakAfter="False"></mobile:Label></td>
56 <td width="20"> </td>
57 <td><mobile:Label id="Label11" runat="server" BreakAfter="True" Text='<%# Ctype(Container, ObjectListItem)("SourceID") %>'> </mobile:Label></td>
58 </tr>
59 <tr>
60 <td><mobile:Label ID="Label12" Runat="server" Text="EscLevel :" BreakAfter="False"></mobile:Label></td>
61 <td width="20"> </td>
62 <td><mobile:Label id="Label13" runat="server" BreakAfter="True" Text='<%# Ctype(Container, ObjectListItem)("EscLevel") %>'> </mobile:Label></td>
63 </tr>
64 <tr>
65 <td><mobile:Label ID="Label14" Runat="server" Text="Date/Time:" BreakAfter="False"></mobile:Label></td>
66 <td width="20"> </td>
67 <td><mobile:Label id="Label15" runat="server" BreakAfter="True" Text='<%# CType(Container, ObjectListItem)("NoticeDtTm")%>'></mobile:Label></td>
68 </tr>
69 <tr>
70 <td colspan="3"><mobile:SelectionList ID="AckCallList" Runat="server" SelectType="Radio" Alignment="Left" Rows="1">
71 <Item Selected="True" Text="Acknowledge Call" Value="Y" />
75 </mobile:SelectionList></td>
76 </tr>
77 <tr>
78 <td colspan="3"><mobile:SelectionList ID="ContactedList" Runat="server" SelectType="Radio" Alignment="Left">
79 <Item Text="Customer Contacted" Selected="True" Value="Y"/>
80 </mobile:SelectionList></td>
81 </tr>
82 <tr>
83 <td colspan="3"><mobile:SelectionList ID="ServiceList" Runat="server" SelectType="Radio" Alignment="Left">
84 <Item Text="Service Initiated" Selected="False" Value="N"/>
85 </mobile:SelectionList></td>
86 </tr>
87 <tr>
88 <td><asp:linkbutton ID="taskAck" CommandName="Acknowledge" Runat="server" >Acknowledge</asp:linkbutton></td>
89 <td width="20"> </td>
90 <td><asp:linkbutton ID="taskBack" CommandName="ListItems" Runat="server">Back</asp:linkbutton></td>
91 </tr>
92 </Table>
93 </mobile:Panel>
94 </ItemDetailsTemplate>
95 </Choice>
96 </DeviceSpecific>
97 <Field DataField="PageID" Title="PageID" />
98 <Field DataField="SourceID" Title="SourceID" />
99 <Field DataField="EscLevel" Title="EscLevel" />
100 <Field DataField="NoticeDtTm" Title="NoticeDtTm" />
101 </mobile:ObjectList>
102 </mobile:Form>
Monday, August 27, 2007 4:19 PM
Answers
-
User1577742094 posted
I resolved the problem.
Dim myAckList As SelectionList = CType(NoticeList1.Selection.FindControl("AckCallList"), SelectionList) If (myAckList.Items(0).Selected) Then acknowledged = True Else acknowledged = False End If
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 27, 2007 7:26 PM