views:

108

answers:

1

I'm using a details view and a sqldatasource control to populate it. Every once in a while i get an error message because more than one row is returned. How can I have the data display in a gridview instead if more than one row is returned?

+1  A: 

Databind to both and put this in the OnDataBound event or wherever appropriate in your code. (Obviously you'll need to tweak the code for the names of your objects)

if(myDataTable.Rows.Count > 1)
{
   myGridView.Visible = true;
   myDetailsView.Visible = false;

}
else
{
  myGridView.Visible = false;
   myDetailsView.Visible = true;
}
David Stratton