Tip::Paging on Demand.....

J

Jignesh Desai

Most of you must have worked on paging feature of DataGrid. its works fine
as long as you have more no of records to show, but if you have configured
20 records per page and no of records you retrieved is less then 20 then
also pager gets rendered at the bottom of the grid showing "1". most of us
do not bother about it , but Clients ,,,uff...but after all client is a
client...if you also encounter such things this is how you solve
SQLDataAdapter.Fill(DS,"Emp")

If DS.Tables("Emp").Rows.Count > MyDataGrid1.PageSize then
MyDataGrid1.AllowPaging = True
Else
MyDataGrid1.AllowPaging = False
End if

MyDataGrid1.DataBind()

I do hate to write these extra lines of code, I hope that .NET team at
Microsoft will incorporate this feature inbuilt in DataGrid itself in their
next release. what do others say...? any better ways?

ya perhaps this could have been reduced to one line also eg.

MyDataGrid1.AllowPaging = ( DS.Tables("Emp").Rows.Count >
MyDataGrid1.PageSize )

Anything better then this?

Regards,
Jignesh Desai
www.dotnetjini.com
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top