Can anyone tell me why I am not allowed to bind a two or multi dimensional array to GridView and possibly suggest how they would deal with similar scenarios?
The array is simply a two dimensional monthly volume array:
Extract from Report class:
// Query all Messages Sent for a Given Month
public string[,] qVolumeByMonth()
{
string[,] volumeByMonth = new string[2,13];
SqlCommand comm = Data.getCommand("spVolumeByMonth");
DataTable table = Data.ExecuteQueryCommand(comm);
// Initialise the array month values
for (int months = 0; months < 12; months++)
{
volumeByMonth[0,months] = Convert.ToString(months + 1);
volumeByMonth[1,months] = "0";
}
volumeByMonth[0,12] = "Total";
volumeByMonth[1,12] = "0";
// Enter the database information into the array
int totalMessages = 0;
for (int rows = 0; rows < table.Rows.Count; rows++)
{
volumeByMonth[1,(Convert.ToInt32(table.Rows[rows]["month"].ToString()) - 1)] = table.Rows[rows]["messages"].ToString();
totalMessages += Convert.ToInt32(table.Rows[rows]["messages"].ToString());
}
volumeByMonth[1,12] = totalMessages.ToString();
return volumeByMonth;
}
This all works to provide a simple two dimensional array. Then when I try to bind to GridView with the following code:
Report report = new Report();
string[,] volumeByMonth = report.qVolumeByMonth();
gvVolumeByMonth.DataSource = volumeByMonth;
gvVolumeByMonth.DataBind();
I get the following eror: "Array was not a one-dimensional array."
Can the GridView simply not be bound to multidimensional arrays?
Kind Regards,
Ian