SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 400 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"


DataViewManager, as part of its ITypedList implementation, exposes the DataTables as properties
in its DataViewSettingCollection. The code checks the dynamic properties of DataViewManager
to see if it can retrieve the DataViewSetting property that matches the DataMember passed into
the Repeater control. If the DataMember is blank, we choose the first DataTable in the DataSet.
Listing 7-3 presents the full source code for the DataSourceHelper class.
Listing 7-3. The DataSourceHelper Class File
using System;
using System.Collections;
using System.ComponentModel;
namespace ControlsBook2Lib.Ch07
{
public class DataSourceHelper
{
public static object ResolveDataSource(object dataSource, string dataMember)
{
if (dataSource == null)
return null;
if (dataSource is IEnumerable)
{
return (IEnumerable)dataSource;
}
else if (dataSource is IListSource)
{
IList list = null;
IListSource listSource = (IListSource)dataSource;
list = listSource.GetList();
if (listSource.ContainsListCollection)
{
ITypedList typedList = (ITypedList)list;
PropertyDescriptorCollection propDescCol =
typedList.GetItemProperties(new PropertyDescriptor[0]);
if (propDescCol.Count == 0)
throw new Exception("ListSource without DataMembers");
PropertyDescriptor propDesc = null;
//Check to see if dataMember has a value, if not, default to first
//property (DataTable) in the property collection (DataTableCollection)
if ((dataMember == null) || (dataMember.


Pages:
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6