mike55 Posted March 31, 2005 Posted March 31, 2005 Hi, Am trying to do paging at the moment, here is the code that I am using: Sub page_Datagrid(ByVal o As Object, ByVal e As DataGridPageChangedEventArgs) dgMembers.CurrentPageIndex = e.NewPageIndex dgMembers.DataSource = dsDataset.Tables("Members") dgMembers.DataBind() End Sub In the Html section of my data grid I have added the following OnPageIndexChanged="page_Datagrid" However when I select a new page on the datagrid, the grid simple disappears. Any suggestions on what is causing this problem?? Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
wessamzeidan Posted March 31, 2005 Posted March 31, 2005 where does dsDataset come from? Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
mike55 Posted March 31, 2005 Author Posted March 31, 2005 where does dsDataset come from? Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then fillDataGrids() End If End Sub Private Sub fillDataGrids() Try Dim daDataAdapter As New SqlDataAdapter connect() MyCommand.CommandType = CommandType.Text MyCommand.CommandText = "SELECT Distinct myMembers.Member_ID, myMembers.Surname, myMembers.Forename, myMembers.DOB, myGroupMembership.Org_ID" & _ " FROM myMembers INNER JOIN" & _ " myGroupMembership ON myMembers.Member_ID = myGroupMembership.Member_ID CROSS JOIN Org_MemberShip" & _ " WHERE myGroupMembership.Org_ID = 'ST466C513'" daDataAdapter = New SqlDataAdapter(MyCommand) daDataAdapter.Fill(dsDataset, "Members") MyCommand.CommandType = CommandType.Text MyCommand.CommandText = "SELECT Distinct myGroups.Group_ID, myGroups.Group_Name, myGroups.Group_Description" & _ " FROM myGroups where myGroups.Org_ID= 'ST466C513' ORDER BY myGroups.Group_ID" daDataAdapter = New SqlDataAdapter(MyCommand) daDataAdapter.Fill(dsDataset, "Groups") MyConnection.Close() dgMembers.DataSource = dsDataset.Tables("Members") dgMembers.DataBind() dgGroups.DataSource = dsDataset.Tables("Groups") dgGroups.DataBind() Catch ex As Exception Throw ex Finally MyConnection.Close() End Try End Sub Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
wessamzeidan Posted March 31, 2005 Posted March 31, 2005 Ok, then you can do this Sub page_Datagrid(ByVal o As Object, ByVal e As DataGridPageChangedEventArgs) dgMembers.CurrentPageIndex = e.NewPageIndex fillDataGrids() End Sub Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
mike55 Posted March 31, 2005 Author Posted March 31, 2005 Yea it works, thanks. But why must I go back to the database in order for paging to work correctly. Since the system has to go back and reload the data this screws up what I am doing. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
wessamzeidan Posted March 31, 2005 Posted March 31, 2005 Because you have to rebind to the datasource each time you change the page in the datagrid, so the datatable should be filled. What you can do is when you fill the dataset for the first time, put it in the session and then use it when binding again. Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
mike55 Posted March 31, 2005 Author Posted March 31, 2005 Have being working on the idea of putting the dataset into a session and then bindin the session everytime, but the datagrid is still refilling. Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.