Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

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)

Posted
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

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)

Posted

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.

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)

Posted
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.

Proudly a Palestinian

Microsoft ASP.NET MVP

My Blog: wessamzeidan.net

Posted

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

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...