datagrid with no rows

  • Thread starter Thread starter kgs
  • Start date Start date
K

kgs

I get argument out of range exception when my datasource
does not have any rows to display in datagrid.
what should i do to display header only
without any rows. Right now if there are no rows i get a
blank area of datagrid. no header no footers.

here is the snippet of code.

Try

mydataGrid.DataSource = myDS
mydataGrid.DataBind()
Catch
--No rows. just display only header.
End Try
 
You modify your code as
Try
MyAdapter.SelectCommand = myDataCommand;
MyDataAdapter.fill(myDs,"myRows")
mydataGrid.DataSource = myDS.Tables("myRows").DefaultView
mydataGrid.DataBind()
Catch
--No rows. just display only header.
End Try
 
Back
Top