ASP.NET, DataGrid & array.

  • Thread starter Thread starter Arcadius A.
  • Start date Start date
A

Arcadius A.

Hello!
I'm trying to bind an array of custom objects to a ASP.NET DataGrid:


private void Page_Load(object sender, System.EventArgs e) {

DataGrid1= new DataGrid();
DataGrid1.DataSource=getAllShow();
Label1.Text+=getAllShow().Length; //This is OK!
//Controls.Add(DataGrid1);
}

The method getAllShow() returns an array of custom objects from a DB.

However Label1 shows a positive number (>2), the datagrid is not
displayed at all. My custom object has setter/getter properties for each
of its fields.

Thanks.

Arcadius.
 
Hi Arcadius

this doesn't apper because you are missing the call to the dataBind
method ... try this it will work

DataGrid k = new DataGrid();
int[] ko = new int[]{3,4};
k.DataSource = ko;
this.Controls.Add(k);
k.DataBind();


i have this note if i may :why don't you define your datagrid as a member
of the class.... it will not apper anyway if it contains no data
hope this would help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top