I am trying to convert the code for the following method.
I am not sure how to go about it since there isn't a equivalent in C# to raise event.
What I want to happen is the Gridview page index changing gets bubbled up to my UI so I can do some code in the event right now nothing happens because this is a custom pager template class that is set to the gridview.
public delegate void PageIndexChanging(object sender, GridViewPageEventArgs e);
public event PageIndexChanging PagerPageIndexChanging;
Private Sub NextLinkBtn_Click(ByVal Sender As Object, ByVal e As EventArgs) Handles NextLinkBtn.Click
Dim gridView As GridView = _container.NamingContainer.NamingContainer
If (gridView.PageIndex < gridView.PageCount - 1) Then
gridView.PageIndex = gridView.PageIndex + 1
End If
FormatPager(gridView)
'Raise PagerPageIndexChanging, passing it the GridView instance using this custom pager template.
RaiseEvent PagerPageIndexChanging(gridView, New GridViewPageEventArgs(gridView.PageIndex))
End Sub
More Detail on the question.
I have a gridview on a aspnet page. I have a class level variable for the pagertemplate
public PagerTemplate GridPagerTemplate = new PagerTemplate();
Then in the grids init method I attach the gridpager template to the grids.PagerTemplate... Everything works it does the first next prev last etc... The problem I am having is after I converted the code from Vb.net to C# That I cant raise the event from the PagerTemplate class in order to get it to execute on the webpage...
protected void ui_grdGuests_Init(object sender, EventArgs e)
{
if (GridPagerTemplate != null)
{
ui_grdGuests.PagerTemplate = GridPagerTemplate;
}
}
Trying to put a break point here in the web form because this is where I need to get it to come after executing the code in the pagertemplate.
protected void ui_grdGuests_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
}
ok I figured it out. Here is how I did it.
Pager template has a delegate and an event
on the web form I did subscribed to that event...