Datagrid paging query

G

Guest

Hi,
When binding a datagrid to a dataset also paging it - when ever we are
navigating from one page to another page - dataset will be refreshed from
database or will it be done with viewstate data?

My key question is whenever data is rebinded how it is been done? Is it
fetch from database or just rebind with data avilable in viewstate?

Thanks and Regards,
Sachi
 
H

Hermit Dave

you will need to refetch the data from the database. ViewState does store
the datasource but i am not not sure whether asp.net saves the complete
datasource to ViewState or only the part pertaining to the current View.
Though you will need the ViewState for paging to work normally.

so in a normal usage
you would bind the datagrid during initial load like this
Page_load(....)
{
if(!Page.IsPostback)
{
SetGridData()'
}
}

private SetGridData()
{

// bind you grid to the datasource here

}

private void GridName_PageIndexChanged(....)
{
GridName.CurrentPageIndex = e.NewPageIndex;
SetGridData();
}

if you disable the ViewState you will need to bind the datagrid everytime on
Page_load()


--

Regards,

Hermit Dave
(http://hdave.blogspot.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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top