Dear Michael:
In regards to my question "what qualifies something as iEnumerable and
therefore a valid datasource", turns out that when I did a search of my code
I must have already investigated (and promptly forgot!) how to make an
IEnumerable object... So, with your reminder, and the piece of code that i
found, case [almost] closed, thanks!!!
My only remaining question is making it IEnumerable, does this really do ALL
that is required to qualify it as a Valid datasource for eg:DataGrid,
etc. -- and what happens when a 'piece' (a field) is missing from the source
(what I mean by this is if you define an xml recordset as a DataSource to eg
a DataGrid -- but some of the records are incomplete and are missing
sub-node/fields in some cases). What happens? Exception? If so, any way that
it can be trapped/corrected, and move on to next fields and rows?
Sky
PS:
Code found was (for anybody who can use it when reading these posts)
Turns out that the "Recipe" is really simple: you only have to enherit from
IEnumerable, and overload the base.GetEnumerator() and MoveNext() and
Current property . No sweat:
public class cSchemaInfoColumnCollection : System.Collections.IEnumerable
{
private System.Collections.Hashtable _List = new
System.Collections.Hashtable();
public cSchemaInfoColumn this[string qName]
{
get
{
return (cSchemaInfoColumn)_List[qName.ToLower()];
}
set
{
_List[qName.ToLower()] = value;
}
}
/*----------*/
public cMyEnumerator GetEnumerator()
{
return new cMyEnumerator(_List);
}
/*----------*/
// Implement the GetEnumerator() method:
System.Collections.IEnumerator
System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/*----------*/
/*----------*/
/*----------*/
// Declare the enumerator and implement the IEnumerator interface:
public class cMyEnumerator: System.Collections.IEnumerator
{
int nIndex;
System.Collections.Hashtable _List;
string[] tKeys;
/*----------*/
public cMyEnumerator(System.Collections.Hashtable qList)
{
_List = qList;
tKeys = new string[_List.Count];
_List.Keys.CopyTo(tKeys,0);
;
nIndex = -1;
}
/*----------*/
public void Reset()
{
nIndex = -1;
}
/*----------*/
public bool MoveNext()
{
nIndex++;
return(nIndex < tKeys.Length);
}
/*----------*/
// The current property on the IEnumerator interface:
object System.Collections.IEnumerator.Current
{
get
{
return(Current);
}
}
/*----------*/
public cSchemaInfoColumn Current
{
get
{
return((cSchemaInfoColumn)_List[tKeys[nIndex]]);
}
}
/*----------*/
}
}
"Michael" <raterus@localhost> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
To answer your first question,
Anything that implements the IEnumerable interface.
http://msdn.microsoft.com/library/de...classtopic.asp
"Sky" <ne********@nospam.xact-solutions.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl... What makes something a valid DataSource? What methods/iterators/etc?
Why do I ask?
I do understand that a DataSet is based on an XML structure...but it's
too table structured for what I am thinking...
Can one read in a an xml file that has various embedded nodes (ie:
records that have children records as XML does best) -- possibly not all the
same length (ie, dif 'column count' for certain 'rows') and try to shove
that into a DataRepeater?
In other words, if I were trying to make a TreeList (Tree with several
columns) based on a DataRepeater, could I read from an XML file? Or do I
have to convert the XML file node by node into a DataSet first?
PS: If anybody has links to someone who has tried this approach, or
similar -- love to hear where!
Best,
Sky