I am having a problem with a RadListView. I am binding the listview on the NeedDataSource event. For some reason, the ItemDataBound event only fires every other item. The listview is in an ItemTemplate of a RadPanelBar. I am attaching these 2 events at runtime.
<telerik:RadPanelItem Text="Contacts" Expanded="true" runat="server"> |
<Items> |
<telerik:RadPanelItem> |
<ItemTemplate> |
<!-- Contact List --> |
<div id="zonePartyContacts" style="padding:5px"> |
<telerik:RadListView ID="rlvContacts" runat="server" ClientDataKeyNames="NameAddrCode" DataKeyNames="NameAddrCode" AllowPaging="true" > |
<LayoutTemplate> |
<div> |
<table cellpadding="0" cellspacing="0" style="padding-top:10px; padding-bottom:5px"> |
<tr valign="top"> |
<td id="itemPlaceholder" runat="server"> |
</td> |
</tr> |
</table> |
<telerik:RadDataPager ID="rdpContacts" runat="server" PageSize="3"> |
<Fields> |
<telerik:RadDataPagerButtonField FieldType="Numeric" /> |
</Fields> |
</telerik:RadDataPager> |
</div> |
</LayoutTemplate> |
<ItemTemplate> |
<td style="padding-right:10px;"> |
<asp:Label ID="lblContact" runat="server" Text='<%# Eval("Name") %>' CssClass="contactName"></asp:Label><br /> |
<div id="zoneTitle" runat="server"> |
<asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label><br /> |
</div> |
<div id="zonePhone" runat="server"> |
<asp:Image ID="imgPhone" runat="server" ImageUrl="~/Images/miniPhone.gif" ImageAlign="Middle" AlternateText="Phone Number" ToolTip="Phone Number" /> <asp:Label ID="lblPhoneNumber" runat="server" Text='<%# Eval("Phone") %>'></asp:Label> <asp:Label ID="lblExtension" runat="server" Text='<%# Eval("PhoneExtension") %>' /><br /> |
</div> |
<div id="zoneFax" runat="server"> |
<asp:Image ID="imgFax" runat="server" ImageUrl="~/Images/miniFax.gif" ImageAlign="Middle" AlternateText="Fax Number" ToolTip="Fax Number" /> <asp:Label ID="lblFaxNumber" runat="server" Text='<%# Eval("Fax") %>'></asp:Label><br /> |
</div> |
<div id="zoneEmail" runat="server"> |
<asp:Image ID="imgEmail" runat="server" ImageUrl="~/Images/miniEmail.gif" ImageAlign="Middle" AlternateText="Email Address" ToolTip="Email Address" /> <asp:Label ID="lblEmail" runat="server" Text='<%# Eval("EmailAddress") %>'></asp:Label><br /> |
</div> |
<asp:HyperLink ID="hlNotes" runat="server" Text="Notes" NavigateUrl="#" Visible="false"></asp:HyperLink> |
<telerik:RadToolTip ID="rttNotes" runat="server" RelativeTo="Element" TargetControlID="hlNotes"></telerik:RadToolTip> |
</td> |
</ItemTemplate> |
</telerik:RadListView> |
</div> |
</ItemTemplate> |
</telerik:RadPanelItem> |
</Items> |
</telerik:RadPanelItem> |
' PageLoad |
rlvContacts = oPanelItemContacts.FindControl("rlvContacts") |
AddHandler rlvContacts.NeedDataSource, AddressOf rlvContacts_NeedDataSource |
AddHandler rlvContacts.ItemDataBound, AddressOf rlvContacts_ItemDataBound |
' NeedDataSource |
Dim oParams As New NameValueCollection |
oParams.Add("ParamNameAddrCode", _PartyCode) |
Dim oResponse As wsProcedureManagement.procedureResponseClass = RunProcedure("GetNameAndAddressContacts", oParams) |
rlvContacts.DataSource = oResponse.DataTableResult |
' ItemDataBound |
If e.Item.ItemType = RadListViewItemType.DataItem Then |
Dim oDataItem As RadListViewDataItem = CType(e.Item, RadListViewDataItem) |
Dim oZone As HtmlGenericControl |
' Show or Hide title if it is available |
oZone = e.Item.FindControl("zoneTitle") |
oZone.Visible = oDataItem.DataItem("Title").ToString.Trim.Length > 0 |
' Show or Hide phone if it is available |
oZone = e.Item.FindControl("zonePhone") |
oZone.Visible = oDataItem.DataItem("Phone").ToString.Trim.Length > 0 AndAlso oDataItem.DataItem("Phone").ToString.Trim <> "0" |
' Show or Hide fax if it is available |
oZone = e.Item.FindControl("zoneFax") |
oZone.Visible = oDataItem.DataItem("Fax").ToString.Trim.Length > 0 AndAlso oDataItem.DataItem("Fax").ToString.Trim <> "0" |
' Show or Hide email if it is available |
oZone = e.Item.FindControl("zoneEmail") |
oZone.Visible = oDataItem.DataItem("EmailAddress").ToString.Trim.Length > 0 |
' Show or Hide notes if they are available |
Dim oNotesLink As HyperLink = e.Item.FindControl("hlNotes") |
oNotesLink.Visible = oDataItem.DataItem("Notes").ToString.Trim.Length > 0 Or oDataItem.DataItem("NotesLine2").ToString.Trim.Length > 0 |
If oNotesLink.Visible Then |
Dim oPopup As RadToolTip = e.Item.FindControl("rttNotes") |
If oDataItem.DataItem("Notes").ToString.Trim.Length > 0 Then |
oPopup.Text = oDataItem.DataItem("Notes").ToString |
End If |
If oDataItem.DataItem("NotesLine2").ToString.Trim.Length > 0 Then |
If oPopup.Text.Length > 0 Then |
oPopup.Text &= "<br />" |
End If |
oPopup.Text &= oDataItem.DataItem("NotesLine2").ToString() |
End If |
End If |
End If |