Friday, March 16, 2012

NewPageIndex error

Imports System.Data.OleDbImports fish.configuration1Public Class CheckReplyFeedbacksInherits System.Web.UI.PageDim dsAs DataSet#Region" Web Form Designer Generated Code "'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()>Private Sub InitializeComponent()End Sub Protected WithEvents lbCRFBAs System.Web.UI.WebControls.LabelProtected WithEvents lbLoggerAs System.Web.UI.WebControls.LabelProtected WithEvents dtgCheckReplyFIAs System.Web.UI.WebControls.DataGrid'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it.Private designerPlaceholderDeclarationAs System.Object Private Sub Page_Init(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles MyBase.Init'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent()End Sub#End Region Private Sub Page_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles MyBase.Load'Put user code to initialize the page here 'load_data()Dim config1As New fish.configuration1 ds = config1.load_data("select * from feedback") bind_data()End Sub Public Sub page_change(ByVal senderAs Object,ByVal eAs DataGridCommandEventArgs) dtgCheckReplyFI.CurrentPageIndex =e.NewPageIndex'load_data() bind_data()End Sub Private Sub bind_data() dtgCheckReplyFI.DataSource = ds dtgCheckReplyFI.DataBind()End SubEnd Class

hello, im doing a paging grid. may i know what is wrong with this code.. because the code in purple keep giving " NewPageIndex" is not a member of 'System.Web.UI.Webcontrols.DataGridCommandEventArgs'. what should i do?

jellyfied

I see 2 things here:

1. Your DataGrid must contain an attribute specifying which method to fire on the page index change event. You do that like this:

 <asp:DataGrid id="DataGrid1" OnPageIndexChanged="Page_Change" runat="server"></asp:DataGrid>
 
2. Your page_change method contains the wrong definition. This is the correct definition:
Protected Sub Page_Change(ByVal sourceAs Object,ByVal eAs System.Web.UI.WebControls.DataGridPageChangedEventArgs)

Hi
DataGridCommandEventArgs doesnt contain NewPageIndex. You are passing the wrong
event arguments. It should be DataGridPageChangedEventArgs as told by jstawski

Thanks


0 comments:

Post a Comment