hi,
i have a tabbed control using multiview.it contains 3 tabbed menu which is loaded at a time during pageload event.these 3 tabbed multiviews contains 3 grid in each view.and each grid should be attached with a paging user control.my below code is working fine for one instance of a user control.i duno how to write code for multiple instance of a user control as i am raisng events.do anybody have a solution for this.
1) code for paging user control.....
<%@ Control Language="
VB" AutoEventWireup="false" CodeFile="paging.ascx.
vb" Inherits="paging" %>
<PRE lang=aspnet id=pre1 style="MARGIN-TOP: 0px">
<table style="width: 55%"><tr><td style="height: 27px; width: 268px;" align="left">(Page <asp:label id="lblCurrentPage" Runat="server"></asp:label>of <asp:label id="lblTotalPages" Runat="server"></asp:label>) </td><td width="27px"><asp:imagebutton id="btnFirst" Runat="server" Enabled="false" ImageUrl="~/images/NavFirstPageDisabled.gif" /> </td>
<td width="27px"><asp:imagebutton id="btnPrevious" Runat="server" Enabled="false"
ImageUrl="~/Images/NavPreviousPageDisabled.gif" /> </td>
<td width="27px"><asp:imagebutton id="btnNext" Runat="server" Enabled="false" ImageUrl="~/Images/NavNextPageDisabled.gif" /></td><td width="27px"><asp:imagebutton id="btnLast" Runat="server" Enabled="false"
ImageUrl="~/Images/NavLastPageDisabled.gif" /> </td>
</tr></table>
</PRE>
Partial Class paging
Inherits System.Web.UI.UserControl
Public Delegate Sub FirstPageEventHandler(ByVal sender As Object, ByVal e As DataNavigatorEventArgs)
Public Delegate Sub LastPageEventHandler(ByVal sender As Object, ByVal e As DataNavigatorEventArgs)
Public Delegate Sub PreviousPageEventHandler(ByVal sender As Object, ByVal e As DataNavigatorEventArgs)
Public Delegate Sub NextPageEventHandler(ByVal sender As Object, ByVal e As DataNavigatorEventArgs)
Public Delegate Sub PageChangedEventHandler(ByVal sender As Object, ByVal e As DataNavigatorEventArgs)
Public Event FirstPage As FirstPageEventHandler
Public Event LastPage As LastPageEventHandler
Public Event PreviousPage As PreviousPageEventHandler
Public Event NextPage As NextPageEventHandler
Public Event PageChanged As PageChangedEventHandler
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim iPages As Integer
iPages = Me.TotalPages
End If
End Sub
Protected Overridable Sub OnPageChanged(ByVal args As DataNavigatorEventArgs)
RaiseEvent PageChanged(Me, args)
' Invoke the delegates.
End Sub
Protected Overridable Sub OnPreviousPage(ByVal args As DataNavigatorEventArgs)
'If Not PreviousPageEventHandler Is Nothing Then
RaiseEvent PreviousPage(Me, args)
' End If
' Invoke the delegates.
End Sub
Protected Overridable Sub OnNextPage(ByVal args As DataNavigatorEventArgs)
RaiseEvent NextPage(Me, args)
' Invoke the delegates.
End Sub
Protected Overridable Sub OnFirstPage(ByVal args As DataNavigatorEventArgs)
RaiseEvent FirstPage(Me, args)
' Invoke the delegates.
End Sub
Protected Overridable Sub OnLastPage(ByVal args As DataNavigatorEventArgs)
RaiseEvent LastPage(Me, args)
' Invoke the delegates.
End Sub
#Region "Get/Set Properties"
Public Property CurrentPage() As Integer
Get
Return Integer.Parse(lblCurrentPage.Text)
End Get
Set(ByVal value As Integer)
lblCurrentPage.Text = Convert.ToString(value)
End Set
End Property
Public Property TotalPages() As Integer
Get
Return Integer.Parse(lblTotalPages.Text)
End Get
Set(ByVal value As Integer)
lblTotalPages.Text = Convert.ToString(value)
End Set
End Property
Public Property NextButtonEnabled() As Boolean
Get
Return btnNext.Enabled
End Get
Set(ByVal value As Boolean)
btnNext.Enabled = value
End Set
End Property
Public Property NextButtonImageUrl() As String
Get
Return btnNext.ImageUrl
End Get
Set(ByVal value As String)
btnNext.ImageUrl = value
End Set
End Property
Public Property PreviousButtonEnabled() As Boolean
Get
Return btnPrevious.Enabled
End Get
Set(ByVal value As Boolean)
btnPrevious.Enabled = value
End Set
End Property
Public Property PreviousButtonImageUrl() As String
Get
Return btnPrevious.ImageUrl
End Get
Set(ByVal value As String)
btnPrevious.ImageUrl = value
End Set
End Property
Public Property FirstButtonEnabled() As Boolean
Get
Return btnFirst.Enabled
End Get
Set(ByVal value As Boolean)
btnFirst.Enabled = value
End Set
End Property
Public Property FirstButtonImageUrl() As String
Get
Return btnFirst.ImageUrl
End Get
Set(ByVal value As String)
btnFirst.ImageUrl = value
End Set
End Property
Public Property LastButtonEnabled() As Boolean
Get
Return btnLast.Enabled
End Get
Set(ByVal value As Boolean)
btnLast.Enabled = value
End Set
End Property
Public Property LastButtonImageUrl() As String
Get
Return btnLast.ImageUrl
End Get
Set(ByVal value As String)
btnLast.ImageUrl = value
End Set
End Property
#End Region
Protected Sub btnFirst_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnFirst.Click
Dim args As New DataNavigatorEventArgs()
args.CurrentPage = Integer.Parse(lblCurrentPage.Text)
args.TotalPages = Integer.Parse(lblTotalPages.Text)
OnFirstPage(args)
End Sub
Protected Sub btnPrevious_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnPrevious.Click
Dim args As New DataNavigatorEventArgs()
args.CurrentPage = Integer.Parse(lblCurrentPage.Text)
args.TotalPages = Integer.Parse(lblTotalPages.Text)
OnPreviousPage(args)
End Sub
Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnNext.Click
Dim args As New DataNavigatorEventArgs()
args.CurrentPage = Integer.Parse(lblCurrentPage.Text)
args.TotalPages = Integer.Parse(lblTotalPages.Text)
OnNextPage(args)
End Sub
Protected Sub btnLast_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnLast.Click
Dim args As New DataNavigatorEventArgs()
args.CurrentPage = Integer.Parse(lblCurrentPage.Text)
args.TotalPages = Integer.Parse(lblTotalPages.Text)
OnLastPage(args)
End Sub
End Class
2)
<asp:MultiView
ID="MultiView1"
runat="server"
ActiveViewIndex="0" >
<asp:View ID="Tab1" runat="server" >
<table width="600" height="400" cellpadding=0 cellspacing=0>
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 1
grid1 code here
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Style="z-index: 104;
left: 146px; position: absolute; top: 589px">
</asp:GridView>
<uc1:paging ID="Paging1" runat="server" />
</td>
</tr>
</table>
</asp:View>
<asp:View ID="Tab2" runat="server">
<table width="600px" height="400px" cellpadding=0 cellspacing=0>
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 2
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" Style="z-index: 104;
left: 146px; position: absolute; top: 589px">
</asp:GridView>
<uc1:paging ID="Paging2" runat="server" />
</td>
</tr>
</table>
</asp:View>
<asp:View ID="Tab3" runat="server">
<table width="600px" height="400px" cellpadding=0 cellspacing=0>
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 3
Grid 3 code here
paging3 instance here
</td>
</tr>
</table>
</asp:View>
</asp:MultiView>
Protected WithEvents gvpaging As Music_paging
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Paging1.CurrentPage = 1
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
bindList()
End If
gvpaging = New paging()
End Sub
Private Sub bindList()
Dim PAGE_SIZE As Integer = 5
Dim totalCount As Integer
Dim con As New SqlConnection(vsess.setConnectionstring(varSession .ConnectionString))
Dim cmd As New SqlCommand("sp_GetRead_Video", con)
cmd.CommandType = CommandType.StoredProcedure
Dim param As SqlParameter = cmd.Parameters.Add("@CurrentPage", SqlDbType.Int)
param.Direction = ParameterDirection.Input
param.Value = 1
param = cmd.Parameters.Add("@PageSize", SqlDbType.Int)
param.Direction = ParameterDirection.Input
param.Value = PAGE_SIZE
param = cmd.Parameters.Add("@TotalRecords", SqlDbType.Int)
param.Direction = ParameterDirection.Output
param = cmd.Parameters.Add("@id", SqlDbType.BigInt)
param.Direction = ParameterDirection.Input
param.Value = 1
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds)
totalCount = CInt(cmd.Parameters("@TotalRecords").Value)
GridView1.DataSource = ds
GridView1.DataBind()
If (totalCount Mod PAGE_SIZE) = 0 Then
Paging1.TotalPages = totalCount / PAGE_SIZE
Else
Paging1.TotalPages = totalCount / PAGE_SIZE + 1
End If
If Paging1.TotalPages > 1 Then
Paging1.NextButtonEnabled = True
Paging1.NextButtonImageUrl = "Images/NavNextPage.gif"
Paging1.LastButtonEnabled = True
Paging1.LastButtonImageUrl = "Images/NavLastPage.gif"
End If
da.Dispose()
cmd.Dispose()
con.Close()
con.Dispose()
end sub
Public Sub FirstPage(ByVal sender As Object, ByVal e As DataNavigatorEventArgs) Handles Paging1.FirstPage
' Decrement the current page index.
If e.CurrentPage > 1 Then
Paging1.CurrentPage = 1
' Get the data for the DataGrid.
bindList()
EnableDisableButtons(e.TotalPages)
End If
End Sub
Public Sub PreviousPage(ByVal sender As Object, ByVal e As DataNavigatorEventArgs) Handles Paging1.PreviousPage
' Decrement the current page index.
If e.CurrentPage > 1 Then
Paging1.CurrentPage -= 1
' Get the data for the DataGrid.
bindList()
EnableDisableButtons(e.TotalPages)
End If
End Sub
Public Sub NextPage(ByVal sender As Object, ByVal e As DataNavigatorEventArgs) Handles Paging1.NextPage
' Decrement the current page index.
If e.CurrentPage <= e.TotalPages Then
Paging1.CurrentPage += 1
' Get the data for the DataGrid.
bindList()
EnableDisableButtons(e.TotalPages)
End If
End Sub
Public Sub LastPage(ByVal sender As Object, ByVal e As DataNavigatorEventArgs) Handles Paging1.LastPage
' Decrement the current page index.
If e.CurrentPage <= e.TotalPages Then
Paging1.CurrentPage = e.TotalPages
' Get the data for the DataGrid.
bindList()
EnableDisableButtons(e.TotalPages)
End If
End Sub
say that i have to bind grid2 and i am calling a bindgrid2 function in the page load for the second instnace of user control,i cannot raise the events here coz of the same name for the sub ie firstpage ,so function overloading problem comes here.
Public Sub FirstPage(ByVal sender As Object, ByVal e As DataNavigatorEventArgs) Handles Paging2.FirstPage
end sub
how to resolve this issue.someone knows a solution.i no gridview by default have a solution for paging and we can use with tabbed menus.but i dont want to use it coz of performance issuses as it is loding all data each time while my stored proceure loads only the data
1-5,5-10 as in paging we have mentioned.