Home All Groups Group Topic Archive Search About

DATAGRID EVENT HANDLERS - NOT FIRING?

Author
6 May 2005 9:23 PM
Frank Walsh
My question is regarding Datagrid's and some trouble I am experiencing
getting events to fire. Here goes:

My Page_Load Looks like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then

BindData()

End If

End Sub

My Pager Handler looks like this:

Sub PageIndexChanged_Click(ByVal sender As Object, ByVal e As
DataGridPageChangedEventArgs)

DataGrid1.CurrentPageIndex = e.NewPageIndex

BindData()

End Sub

My ASPX FILE DATAGRID DEF. LOOKS LIKE THIS

   asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 256px"
    runat="server" OnPageIndexChanged="PageIndexChanged_Click"
AllowPaging="True" PageSize="25"
    AllowSorting="True"></asp:datagrid
So I would expect this code to fire the pager handler when i click a number
based on all the examples I've found. It however does not. Now I can get the
event to fire by removing the Not Ispostback clause. However, this ends up
calling my bindata function twice, once in page_load and once in the
handler. I have viewstate enabled on page, what am i missing?

Thank You

Frank.Wa***@gmail.com

Author
7 May 2005 11:34 AM
Scott M.
Your grid's event handler doesn't seem to have a "Handles
DataGrid1.PageIndex Changed" clause at the end.


Show quoteHide quote
"Frank Walsh" <Frank.Wa***@gmail.com> wrote in message
news:uoDWfHoUFHA.3620@TK2MSFTNGP09.phx.gbl...
> My question is regarding Datagrid's and some trouble I am experiencing
> getting events to fire. Here goes:
>
> My Page_Load Looks like this:
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> If Not Page.IsPostBack Then
>
> BindData()
>
> End If
>
> End Sub
>
> My Pager Handler looks like this:
>
> Sub PageIndexChanged_Click(ByVal sender As Object, ByVal e As
> DataGridPageChangedEventArgs)
>
> DataGrid1.CurrentPageIndex = e.NewPageIndex
>
> BindData()
>
> End Sub
>
> My ASPX FILE DATAGRID DEF. LOOKS LIKE THIS
>
>   asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
> absolute; TOP: 256px"
>    runat="server" OnPageIndexChanged="PageIndexChanged_Click"
> AllowPaging="True" PageSize="25"
>    AllowSorting="True"></asp:datagrid
> So I would expect this code to fire the pager handler when i click a
> number based on all the examples I've found. It however does not. Now I
> can get the event to fire by removing the Not Ispostback clause. However,
> this ends up calling my bindata function twice, once in page_load and once
> in the handler. I have viewstate enabled on page, what am i missing?
>
> Thank You
>
> Frank.Wa***@gmail.com
>
>
>