/// <include file='doc\WmlObjectListAdapter.uex' path='docs/doc[@for="WmlObjectListAdapter.RenderItemsList"]/*' /> protected virtual void RenderItemsList(WmlMobileTextWriter writer) { bool rendersAcceptsInline = Device.RendersWmlDoAcceptsInline; bool rendersSelectsAsMenuCards = Device.RendersWmlSelectsAsMenuCards; bool rendersBreaksAfterAnchor = Device.RendersBreaksAfterWmlAnchor; int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; if (pageSize == 0 || items.Count == 0) { return; } bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresSecondScreen = HasItemDetails() || (!onlyHasDefaultCommand && HasCommands()); bool itemRequiresHyperlink = requiresSecondScreen || hasDefaultCommand; writer.EnterLayout(Style); int[] tableFieldIndices = null; if (ShouldRenderAsTable() && (tableFieldIndices = Control.TableFieldIndices).Length != 0) { writer.BeginCustomMarkup(); int fieldCount = tableFieldIndices.Length; writer.Write("<table columns=\""); writer.Write(fieldCount.ToString(CultureInfo.InvariantCulture)); writer.WriteLine("\">"); if (ShouldRenderTableHeaders()) { writer.Write("<tr>"); foreach (int fieldIndex in tableFieldIndices) { writer.Write("<td>"); writer.RenderText(Control.AllFields[fieldIndex].Title); writer.Write("</td>"); } writer.WriteLine("</tr>"); } for (int i = 0; i < pageSize; i++) { ObjectListItem item = items[pageStart + i]; writer.Write("<tr>"); for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); if (field == 0 && itemRequiresHyperlink) { RenderPostBackEvent(writer, requiresSecondScreen ? String.Format(CultureInfo.InvariantCulture, _showMoreFormatAnchor, item.Index) : item.Index.ToString(CultureInfo.InvariantCulture), GetDefaultLabel(GoLabel), false, item[tableFieldIndices[0]], false, WmlPostFieldType.Raw); } else { writer.RenderText(item[tableFieldIndices[field]]); } writer.Write("</td>"); } writer.WriteLine("</tr>"); } writer.WriteLine("</table>"); writer.EndCustomMarkup(); } else { int labelFieldIndex = Control.LabelFieldIndex; ObjectListField labelField = Control.AllFields[labelFieldIndex]; writer.EnterFormat(Style); for (int i = 0; i < pageSize; i++) { ObjectListItem item = items[pageStart + i]; if (itemRequiresHyperlink) { RenderPostBackEvent(writer, requiresSecondScreen ? String.Format(CultureInfo.InvariantCulture, _showMoreFormatAnchor, item.Index) : item.Index.ToString(CultureInfo.InvariantCulture), GetDefaultLabel(GoLabel), false, item[labelFieldIndex], true, WmlPostFieldType.Raw); } else { writer.RenderText(item[labelFieldIndex], true); } } writer.ExitFormat(Style); } writer.ExitLayout(Style); }