Hi everyone,

I'm trying to develop a control that will allow a page developer to use
their own XML documents to populate a page's contents instead of having to
conform to some pre-defined scheme. This sounds weird, but it's mainly to
give them the freedom to develop their own tags, number of elements, etc.
As such, I'm trying to have the size and contents of an array populated
dynamically, as opposed to hard-coded.

In the GetArrayContents method below, I'm trying to read the DataColumns
from a DataTable and write a string value to be read by the ReadSlides
method to populate a jagged array, but I keep getting a "Index Outside the
Bounds of the Array" error. I thought this would be OK, but apparently not.
I wrote the string contents of the GetArrayContents out to the browser, and
the format seems to be correct.

// set a jagged array of images & captions to use by reading data from an
XML file
private string[][] ReadSlides(string filepath)
{
FileStream fs = new
FileStream(filepath,FileMode.Open,FileAccess.Read);
StreamReader sr = new StreamReader(fs);
DataSet ds = new DataSet();

ds.ReadXml(sr);
fs.Close();

DataTable table = ds.Tables[0];
DataRow[] rows = table.Select();

string[][] contents = new string[rows.Length][];
for(int i=0;i<rows.Length;i++)
{
// THIS IS HOW THE ARRAY SHOULD BE COMING POPULATED, AND
IT'S THE SAME LINE I'M TRYING TO CREATE
// contents[i] = new string[] {
rows[i]["image"].ToString(),rows[i]["alt"].ToString(),rows[i]["title"].ToStr
ing(),rows[i]["caption"].ToString() };
contents[i] = new string[] { GetArrayContents(table) };
}

return contents;
}

// helper method that automates the population of the jagged array
private string GetArrayContents(DataTable table)
{
string arrayContents = string.Empty;

foreach(DataColumn col in table.Columns)
{
arrayContents += "rows[i][\"" + col.ColumnName +
"\"].ToString(),";
}

return arrayContents;
}

Thanks!