datagrid with no rows

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
 
V

vijay

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
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top