Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataBinding in DataGrid

Status
Not open for further replies.

lesliedomjones

Programmer
Feb 4, 2003
3
0
0
IN
hello all,
I have created a two dimenstional array and try to bind to a datagrid as shown below. But I could not get the array values in the datagrid. Instead It is binding the properties of the array.. I could not find why it is happening. Could any one please explain why it is happening and how databinding is done in datagrid or asp.net?

the code is,
string[][] arr = new string[2][];
arr[0][] = {"a", "b"};
arr[1][] = {"c", "d"};

datagrid.DataSource = arr;
datagrid.DataBind();

Thanks in Advance

Regards,
leslie
 

You can bind an array as datasource for a grid (in this case for example, the first array of jagged array),and can see the values that are containd in it:

string[][] arr = new string[2][];

arr[0] = new String[] {"a","b"};
arr[1] = new String[] {"c","d"};

DataGrid1.DataSource = arr[0];
DataGrid1.DataBind();//The result is: a,b in datagrid

When you bind a jagged array, the values contained in this object that can be displayed in datagrid are the attributes of jagged array.
(You can look in msdn for the objects that can be data source and the interfaces that have to implement.)

Hope this help,
Mary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top