|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Paging by example - help - still no luck....I was looking at the example provided on: http://www.4guysfromrolla.com/webtech/072101-1.2.shtml for paging. I am using Visual Studio 2003 - Microsoft Development Environment 2003 For paging the page url mentions setting properties to be set as: AllowPaging="True" PageSize="15" OnPageIndexChanged="dgPopularFAQs_Paged"> Ok. I am looking at my datagrid in the design view - there is a Allow Paging, PageSize - but no OnPageIndexChanged!! I went to the code behine - at the top selected my datagrid in the top left drop down menu, and could not find OnPageIndexChanged in the declarations menu. There is a 'PageIndexChanged' changed - is that it? Well, I put this code in that area (using a Dataset called ds): Private Sub dg_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dg.PageIndexChanged dg.CurrentPageIndex = e.NewPageIndex dg.DataBind() End Sub The paging numbers show up on the grid, but when I hit any of the numbers - the same screen shows up - 10 records, it does not advance (set to 10 in the property builder). It never advances. In my page load I have this: 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 dgDataBind() End If End Sub Any help? Thanks, Tmuld Tmuld,
Why don't you just use the samples on MSDN for paging a datagrid, they are in my opinion very well. One of them http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskCodePagingInDataGridWebControlVisualBasic.asp I hope this helps, Cor Thanks - it does work very well!
I still have some issues. I used the MSDN code and it sort of works. Now the paging works, but when I hit the number - it does not show my records until I hit the search button again. I thought it would go to the next records automatically. Not sure why? Do I need to do some sort of refresh at the button level? [Plus I also do not understand this line: dsQuery = CType(Session("dataset"), DataSet1). I already have a dataset defined at design time - what does this do? ] Here is my code: - my dataset is called 'ds' 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 With dg .AllowPaging = True .PagerStyle.Mode = PagerMode.NumericPages .PageSize = 5 .PagerStyle.PageButtonCount = 5 End With If IsPostBack Then ds = CType(Session("dataset"), DataSet1) Else daQuery.Fill(ds) Session("dataset") = ds DataBind() End If End Sub The button code->filters out data with a dataview. So after the page button is pressed - one gets a blank screen untill the button is pressed again - then it moves to the next results. Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click Dim Count As Integer Dim dv As DataView = ds.Tables("DB").DefaultView dv.RowFilter = "Title like '%" & txt.Text & "%' OR Address like '%" & txt.Text & "%'" Count = dv.Count dg.DataSource = dv dg.DataBind() lblCount.Text = Count End Sub Paging: Private Sub dg_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dg.PageIndexChanged dg.CurrentPageIndex = e.NewPageIndex dg.DataBind() End Sub Tmuld,
A webpage is not persistent, what means that with every send and get back all the data on serverside is removed. For that are some solutions for with is the session the most simple. The most simple because it can fit automatically (serialized) the dataset. Therefore you have to set that dataset again when there is a postback to the session (and as well when you do a fill to renew it). Your other question is what I am always struggling with as well, so take some time to find that. Cor
Help with Debugging
Get processes list problem (win 2000) VB6 - Unable to read Text File iHttpModule and Virtual Directories Custom Collections : overriding toString Response.Redirect("WebForm1.aspx") Sharing references/members Web Application using VB.NET VB.net Ablauf vom packen eines Projekts DateDiff Error |
|||||||||||||||||||||||