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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DatGrid record count

Status
Not open for further replies.

sanctified

Programmer
Mar 9, 2006
65
GB
Hi Group,
How can I detect whether a datgrid control has any records? I need to check for no records being present.

TIA
 
You could check the Rows.Count value of it's datasource


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks Guys,
I'm not sure where what you've both suggested will fit into my current syntax.
The datagrid is bound on the onload event of my form using a datatable.
Currently my code where I pass the datarow of the datatable is this on the btn_submit click event:

Dim objdt As New DataTable
Dim dInfoElement
Dim dRows As DataRow
objdt = Session("tbl")
dRows = objdt.Rows(0) <-- this line gives an error if there are no records in the datagrid

I'm passing dRows to a function in a class.

tia
 
try
Code:
if  objdt.Rows.count>0 then 
'work
end if

Where are using a datagrid? The code only shows datatable and datarows.
 
you might also want to convert the session var to a datatable to:

Code:
 objdt = ctype( Session("tbl"), data.datatable)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top