do not receive event in Datagrid

Discussion in 'ASP .Net Building Controls' started by ton, Feb 9, 2004.

  1. ton

    ton Guest

    Hi,
    I'm using a datagrid, which I fill with a subroutine :
    When filling the initial 5 rows I want to show the next 5 rows, but the
    screen is blank. No control is visible. It looks if the nextprev function is
    not executed. What ever code is written there (even when I'm sure it will
    result in an error, nothing happened). Why ?
    In the beginning of my servercontrol I have:
    Public Class dbWebList

    Inherits System.Web.UI.WebControls.WebControl

    Implements INamingContainer

    The function to show the grid:

    Public Function ShowGrid(Optional ByVal startpage As Integer = 0) As Boolean

    Dim datagrid As DataGrid


    Dim SQLdataAdapter As SqlDataAdapter

    Dim SQLconnection As SqlConnection

    Dim dataset As DataSet

    SQLconnection = New SqlConnection("workstation id=VRS7;packet size=4096;user
    id=sa;data source=VRS7\VRS7;persist security info=False;initial
    catalog=Compass")

    SQLdataAdapter = New SqlDataAdapter("select * from tuning",
    SQLconnection.ConnectionString)

    dataset = New DataSet

    SQLdataAdapter.Fill(dataset)

    Datagrid = New DataGrid

    Datagrid.AllowPaging = True

    AddHandler Datagrid.PageIndexChanged, AddressOf Me.nextprev

    Datagrid.PageSize = 5

    Datagrid.DataSource = dataset

    Datagrid.DataBind()

    Controls.Add(Datagrid)

    end sub

    Private Sub nextprev(ByVal sender As Object, ByVal e As
    DataGridPageChangedEventArgs)

    Dim datagrid1 As DataGrid

    '' DataGrid = CType(sender, DataGrid) ''(

    _Page = e.NewPageIndex

    ShowGrid(e.NewPageIndex)

    '' Exit Sub

    '' datagrid.CurrentPageIndex = e.NewPageIndex

    '' datagrid.DataBind()

    ''Controls.Add(datagrid)

    End Sub
     
    ton, Feb 9, 2004
    #1
    1. Advertising

  2. ton

    ton Guest

    Re: do not receive event in Datagrid NO PREVIOUS possiible

    I allready got the event. The reason was that the createchildrecords was
    fired, which did not give the gridcontrol, so the event did not do anything
    either.

    My next problem is the the NEXT butto (>) workt fine, but the previous can
    only be pushed once, but does not generate the previous page.
    I expect it has to do with the way these controls are created but do not
    have a clue why this is not working.
    thanks
    ton

    "ton" <> schreef in bericht
    news:c08587$snt$1.nb.home.nl...
    > Hi,
    > I'm using a datagrid, which I fill with a subroutine :
    > When filling the initial 5 rows I want to show the next 5 rows, but the
    > screen is blank. No control is visible. It looks if the nextprev function

    is
    > not executed. What ever code is written there (even when I'm sure it will
    > result in an error, nothing happened). Why ?
    > In the beginning of my servercontrol I have:
    > Public Class dbWebList
    >
    > Inherits System.Web.UI.WebControls.WebControl
    >
    > Implements INamingContainer
    >
    > The function to show the grid:
    >
    > Public Function ShowGrid(Optional ByVal startpage As Integer = 0) As

    Boolean
    >
    > Dim datagrid As DataGrid
    >
    >
    > Dim SQLdataAdapter As SqlDataAdapter
    >
    > Dim SQLconnection As SqlConnection
    >
    > Dim dataset As DataSet
    >
    > SQLconnection = New SqlConnection("workstation id=VRS7;packet

    size=4096;user
    > id=sa;data source=VRS7\VRS7;persist security info=False;initial
    > catalog=Compass")
    >
    > SQLdataAdapter = New SqlDataAdapter("select * from tuning",
    > SQLconnection.ConnectionString)
    >
    > dataset = New DataSet
    >
    > SQLdataAdapter.Fill(dataset)
    >
    > Datagrid = New DataGrid
    >
    > Datagrid.AllowPaging = True
    >
    > AddHandler Datagrid.PageIndexChanged, AddressOf Me.nextprev
    >
    > Datagrid.PageSize = 5
    >
    > Datagrid.DataSource = dataset
    >
    > Datagrid.DataBind()
    >
    > Controls.Add(Datagrid)
    >
    > end sub
    >
    > Private Sub nextprev(ByVal sender As Object, ByVal e As
    > DataGridPageChangedEventArgs)
    >
    > Dim datagrid1 As DataGrid
    >
    > '' DataGrid = CType(sender, DataGrid) ''(
    >
    > _Page = e.NewPageIndex
    >
    > ShowGrid(e.NewPageIndex)
    >
    > '' Exit Sub
    >
    > '' datagrid.CurrentPageIndex = e.NewPageIndex
    >
    > '' datagrid.DataBind()
    >
    > ''Controls.Add(datagrid)
    >
    > End Sub
    >
    >
     
    ton, Feb 9, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carl Prothman [MVP]
    Replies:
    2
    Views:
    5,613
    Carl Prothman [MVP]
    Aug 14, 2003
  2. gabriel
    Replies:
    2
    Views:
    3,728
    gabriel
    Aug 5, 2005
  3. wang xiaoyu
    Replies:
    0
    Views:
    864
    wang xiaoyu
    Jun 25, 2003
  4. Marc ENGEL
    Replies:
    0
    Views:
    443
    Marc ENGEL
    Jul 30, 2003
  5. Replies:
    0
    Views:
    125
Loading...

Share This Page