G
Guest
*Help*
I have a collectionbase derived list binding to an ASP.NET
Repeater control (I even added a sort method or two)...
However:
I get this error Message in ASP.NET binding a
collectionbase derived list to a data grid:
A field or property with the name 'Count' was not found on the selected
datasource.
In an windows application binding the same collectionbase
derived list throws this error:
An unhandled exception of type 'System.Reflection.TargetInvocationException'
occurred in system.windows.forms.dll
Additional information: Property accessor 'Count' on object
'SybaseInformation.Entity.SybaseDb' threw the following exception:'Object
does not match target type.'
/* code begin */
using System;
using System.Text;
using System.Collections;
using SybaseInformation.Entity;
namespace SybaseInformation.Lists
{
/// <summary>
/// Summary description for SybaseDbList.
/// </summary>
public class SybaseDbList : CollectionBase
{
#region Constructor
public SybaseDbList() : base()
{
//
// TODO: Add constructor logic here
//
}
#endregion
#region Destructor
~SybaseDbList()
{
List.Clear();
}
#endregion
#region List CollectionBase Specific Routines
public SybaseDbList this[int index]
{
get
{
return (SybaseDbList) List[index];
} // get
set
{
List[index] = value;
} // set
} // public SybaseDbList this[int index])
public int Add(SybaseDb item)
{
SybaseDb obj = new SybaseDb(item);
return List.Add(obj);
} // public int Add(SybaseDb item)
public bool Contains(string sDatabaseName)
{
// this is an not the standard Contains
// as found in CollectionBase
bool bInList = false;
int nWhereAt = 0;
SybaseDb sd = null;
if (List.Count > 0)
{
while ((nWhereAt < List.Count) && (bInList == false))
{
sd = (SybaseDb) List[nWhereAt];
if (sd.DBName == sDatabaseName)
{
bInList = true;
} // if (sd.DBName == sDatabaseName)
nWhereAt++;
} // while ((nWhereAt < List.Count) && (bInList == false))
} // if (List.Count > 0)
return bInList;
} // public bool Contains(string sColumn)
public void CopyTo(SybaseDbList[] array, int index)
{
List.CopyTo(array, index);
} // public void CopyTo(SybaseDbList[] array, int index)
public int IndexOf(SybaseDb item)
{
return List.IndexOf(item);
} // public int IndexOf(SybaseDb item)
public int FindDatabaseName(string sDatabaseName)
{
int nWhereAt = 0;
int nRetVal = -1;
bool bInList = false;
SybaseDb sd = null;
if (List.Count > 0)
{
while ((nWhereAt < List.Count) && (bInList == false))
{
sd = (SybaseDb) List[nWhereAt];
if (sd.DBName == sDatabaseName)
{
bInList = true;
nRetVal = nWhereAt;
} // if (sd.DBName == sDatabaseName)
nWhereAt++;
} // while ((nWhereAt < List.Count) && (bInList == false))
} // if (List.Count > 0)
return nRetVal;
} // public int FindColumn(string sColumn)
public void Insert(int index, SybaseDb item)
{
List.Insert(index, item);
} // public void Insert(int index, SybaseDb item)
public void Remove(SybaseDbList item)
{
List.Remove(item);
} // public void Remove(SybaseDbList item)
public new void RemoveAt(int index)
{
Remove(this[index]);
} // public new void RemoveAt(int index)
public override string ToString()
{
int i = 0;
StringBuilder builder = new StringBuilder(List.Count);
for (i = 0; i < List.Count; i++)
{
builder.Append(List.ToString());
} // for (i = 0; i < List.Count; i++)
return builder.ToString();
} // public override string ToString()
public void Sort(sortDirection sOrder, sortOptions sOptions)
{
IComparer DBNameSorter = new SybaseDbComparer(sOrder,sOptions);
InnerList.Sort(DBNameSorter);
}
#endregion
}
}
/* code end */
I have a collectionbase derived list binding to an ASP.NET
Repeater control (I even added a sort method or two)...
However:
I get this error Message in ASP.NET binding a
collectionbase derived list to a data grid:
A field or property with the name 'Count' was not found on the selected
datasource.
In an windows application binding the same collectionbase
derived list throws this error:
An unhandled exception of type 'System.Reflection.TargetInvocationException'
occurred in system.windows.forms.dll
Additional information: Property accessor 'Count' on object
'SybaseInformation.Entity.SybaseDb' threw the following exception:'Object
does not match target type.'
/* code begin */
using System;
using System.Text;
using System.Collections;
using SybaseInformation.Entity;
namespace SybaseInformation.Lists
{
/// <summary>
/// Summary description for SybaseDbList.
/// </summary>
public class SybaseDbList : CollectionBase
{
#region Constructor
public SybaseDbList() : base()
{
//
// TODO: Add constructor logic here
//
}
#endregion
#region Destructor
~SybaseDbList()
{
List.Clear();
}
#endregion
#region List CollectionBase Specific Routines
public SybaseDbList this[int index]
{
get
{
return (SybaseDbList) List[index];
} // get
set
{
List[index] = value;
} // set
} // public SybaseDbList this[int index])
public int Add(SybaseDb item)
{
SybaseDb obj = new SybaseDb(item);
return List.Add(obj);
} // public int Add(SybaseDb item)
public bool Contains(string sDatabaseName)
{
// this is an not the standard Contains
// as found in CollectionBase
bool bInList = false;
int nWhereAt = 0;
SybaseDb sd = null;
if (List.Count > 0)
{
while ((nWhereAt < List.Count) && (bInList == false))
{
sd = (SybaseDb) List[nWhereAt];
if (sd.DBName == sDatabaseName)
{
bInList = true;
} // if (sd.DBName == sDatabaseName)
nWhereAt++;
} // while ((nWhereAt < List.Count) && (bInList == false))
} // if (List.Count > 0)
return bInList;
} // public bool Contains(string sColumn)
public void CopyTo(SybaseDbList[] array, int index)
{
List.CopyTo(array, index);
} // public void CopyTo(SybaseDbList[] array, int index)
public int IndexOf(SybaseDb item)
{
return List.IndexOf(item);
} // public int IndexOf(SybaseDb item)
public int FindDatabaseName(string sDatabaseName)
{
int nWhereAt = 0;
int nRetVal = -1;
bool bInList = false;
SybaseDb sd = null;
if (List.Count > 0)
{
while ((nWhereAt < List.Count) && (bInList == false))
{
sd = (SybaseDb) List[nWhereAt];
if (sd.DBName == sDatabaseName)
{
bInList = true;
nRetVal = nWhereAt;
} // if (sd.DBName == sDatabaseName)
nWhereAt++;
} // while ((nWhereAt < List.Count) && (bInList == false))
} // if (List.Count > 0)
return nRetVal;
} // public int FindColumn(string sColumn)
public void Insert(int index, SybaseDb item)
{
List.Insert(index, item);
} // public void Insert(int index, SybaseDb item)
public void Remove(SybaseDbList item)
{
List.Remove(item);
} // public void Remove(SybaseDbList item)
public new void RemoveAt(int index)
{
Remove(this[index]);
} // public new void RemoveAt(int index)
public override string ToString()
{
int i = 0;
StringBuilder builder = new StringBuilder(List.Count);
for (i = 0; i < List.Count; i++)
{
builder.Append(List.ToString());
} // for (i = 0; i < List.Count; i++)
return builder.ToString();
} // public override string ToString()
public void Sort(sortDirection sOrder, sortOptions sOptions)
{
IComparer DBNameSorter = new SybaseDbComparer(sOrder,sOptions);
InnerList.Sort(DBNameSorter);
}
#endregion
}
}
/* code end */