pagging in asp.net datagrid
hi guys
i have done pagging in asp.net datagrid, and it is working perfectly
my code is here,
Private Sub BindGrid()
Dim cnn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As New DataSet()
cnn = New SqlConnection(ConfigurationSettings.AppSettings(). Item("ConnectionString"))
da = New SqlDataAdapter("select lastname,firstname,city from employees", cnn)
da.Fill(ds, "employees")
DataGrid1.DataSource = ds
DataGrid1.DataMember = "employees"
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
End Sub
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
but now what i m thinking is that if i have 50 pages then i have to call bindgrid() from datagrid1_pageindexchanged() 50 times.so bindgrid() function has code to connect with sql server, so what happen , it will connect everytime with server then get dataset and then bind datagrid? plz if u know what happen plz explain me , and if i m right then what about speed?
thax
|