As this is my first project, I really do not have much idea to debug this. I have a listview. I am writing code manually to populate listview. As the listview is very large, I have a search button where user enters a search string. I am trying to build a sql string from here and populate the listview. Everything works fine but when I click on next page, it does not include the search string. I think it is just populating the 2nd page without the search criteria. If I remove the data pager control, it works fine. I am not able to put proper code datapger_PagePropertiesChanging. I appreciate if someone can help me with this.
Here is my list view markup:
<asp:ListView ID="lvContractors" runat="server" OnPagePropertiesChanging="lvContractors_PagePropertiesChanging">
<LayoutTemplate>
<div class="ListViewGrid">
<table class="tblpadding">
<tr>
<th class="HeaderStyle">
Contractor Number
</th>
<th class="HeaderStyle">
First Name
</th>
<th class="HeaderStyle">
Last Name
</th>
<th class="HeaderStyle">
View
</th>
<th class="HeaderStyle">
Edit
</th>
</tr>
<tbody><asp:PlaceHolder runat="server" ID="itemPlaceholder" /></tbody>
</table>
</div> <!-- End of ListViewGrid -->
</LayoutTemplate>
<ItemSeparatorTemplate> <td> <hr /> </td>
</ItemSeparatorTemplate>
<ItemTemplate>
<div >
<tr>
<td class="RowStyle"><%#Eval("ContractorNumber")%></td>
<td class="RowStyle"><%#Eval("FirstName")%></td>
<td class="RowStyle"><%#Eval("LastName")%></td>
<td class="RowStyle">
<asp:HyperLink ID="lnkView" runat="server" CssClass="link"
NavigateUrl='<%# "ContractorEdit.aspx?ID=" + Eval("ContractorNumber") + "&Mode=" + "CV" %>'
Target="_blank" Text="View" />
</td>
<td class="RowStyle">
<asp:HyperLink ID="lnkEdit" runat="server" CssClass="link"
NavigateUrl= '<%# "ContractorEdit.aspx?ID=" + Eval("ContractorNumber") + "&Mode=" + "CE" %>'
Text="Edit"> </asp:HyperLink>
</tr>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div>
<tr>
<td class="AlternatingRowStyle"><%#Eval("ContractorNumber")%></td>
<td class="AlternatingRowStyle"><%#Eval("FirstName")%></td>
<td class="AlternatingRowStyle"><%#Eval("LastName")%></td>
<td class="AlternatingRowStyle">
<asp:HyperLink ID="lnkView" runat="server" CssClass="link"
NavigateUrl='<%# "Contractor.aspx?ID=" + Eval("ContractorNumber")%>'
Target="_blank" Text="View" />
</td>
<td class="AlternatingRowStyle">
<asp:HyperLink ID="lnkEdit" runat="server" CssClass="link"
NavigateUrl= '<%# "ContractorEdit.aspx?ID=" + Eval("ContractorNumber") + "&Mode=" + "CE" %>'
Text="Edit"> </asp:HyperLink>
</tr>
</div>
</AlternatingItemTemplate>
<ItemSeparatorTemplate>
<tr>
<td colspan="5" class="itemseparator"></td>
</tr>
</ItemSeparatorTemplate>
</asp:ListView>
<div class="pager">
<asp:DataPager PageSize="20" ID="DataPagerContractor" runat="server" PagedControlID="lvContractors"
NextPreviousButtonCssClass="PrevNext"
CurrentPageLabelCssClass="CurrentPage"
NumericButtonCssClass="PageNumber">
<fields>
<asp:NumericPagerField
PreviousPageText="< Prev"
NextPageText="Next >"
ButtonCount="10"
NextPreviousButtonCssClass="PrevNext"
CurrentPageLabelCssClass="CurrentPage"
NumericButtonCssClass="PageNumber" />
</fields>
</asp:DataPager>
</div>
</div> Code behind this: Partial Class Contractor
Inherits System.Web.UI.Page
Private txtKeywordSearchWhereClause As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Session("Clicked") = "Contractor"
End If
If Not DBNull.Value.Equals(txtKeywordSearchWhereClause) Then
LoadContractors(txtKeywordSearchWhereClause)
Else
LoadContractors("")
End If
End Sub
Private Sub LoadContractors(ByVal strSearch As String)
Dim strConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Conn").ConnectionString)
strConn.Open()
Dim sql As String = "SELECT * FROM tblContractor1"
If Not strSearch = "" Then
sql = sql & strSearch
sql = sql & " ORDER BY LastName"
End If
Dim da As SqlDataAdapter = New SqlDataAdapter(sql, strConn)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
lvContractors.DataSource = dt
lvContractors.DataBind()
End Sub
Protected Sub buttonAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles buttonAdd.Click
Response.Redirect("ContractorEdit.aspx", False)
End Sub
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
' Keyword Search
Dim txtKeywordSearch As String = txtSearch.Text
Dim txtWhereClause As String = ""
If txtKeywordSearch.Trim() <> "" Then
txtWhereClause = " WHERE FirstName LIKE '%" + txtKeywordSearch + "%'"
txtWhereClause = txtWhereClause + " OR LastName LIKE '%" + txtKeywordSearch + "%'"
txtWhereClause = txtWhereClause + " OR ContractorNumber LIKE '%" + txtKeywordSearch + "%'"
txtKeywordSearchWhereClause = txtWhereClause
End If
LoadContractors(txtKeywordSearchWhereClause)
End Sub
Protected Sub lvContractors_PagePropertiesChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.PagePropertiesChangingEventArgs) Handles lvContractors.PagePropertiesChanging
DataPagerContractor.SetPageProperties(e.StartRowIndex, e.MaximumRows, False)
'rebind List View
If Not DBNull.Value.Equals(txtKeywordSearchWhereClause) Then
LoadContractors(txtKeywordSearchWhereClause)
Else
LoadContractors("")
End If
End Sub
End Class
Sorry to say, but this is not possible with the datapager (at least in ASP.Net 3.5).
The only solution is to write your own pager from scratch as the only querystring parameter the datapager can pass is the page number.
Related
<section class="reg" id="reg">
<div class="row">
<div class="col-md-20">
<h3>Registration</h3>
<div class="box-area">
<div class="box-area-icon">
<div class="heading">
<h2>Registration</h2>
<h2><i class="fa fa-users"></i></h2>
</div>
</div>
<table style="width: 100%;" align="center">
<tr>
<td>Name</td>
<td class="text-left">
<asp:TextBox ID="vreg_name_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Contacct No.</td>
<td class="text-left">
<asp:TextBox ID="vreg_con_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Email</td>
<td class="text-left">
<asp:TextBox ID="vreg_email_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>State</td>
<td class="text-left">
<asp:DropDownList ID="vreg_state_dl" runat="server">
<asp:ListItem>gujrat</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>City</td>
<td class="text-left">
<asp:DropDownList ID="vreg_city_dl" runat="server">
<asp:ListItem>surat</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Location</td>
<td class="text-left">
<asp:DropDownList ID="vreg_loc_dl" runat="server">
<asp:ListItem>katargam</asp:ListItem>
<asp:ListItem>adajan</asp:ListItem>
<asp:ListItem>piplod</asp:ListItem>
<asp:ListItem>chok</asp:ListItem>
</asp:DropDownList>
<br />
<asp:TextBox ID="vreg_area_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Username</td>
<td class="text-left">
<asp:TextBox ID="v_user_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Password</td>
<td class="text-left">
<asp:TextBox ID="v_pass_txt" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Confirm password</td>
<td class="auto-style3">
<asp:TextBox ID="v_conf_pass_txt" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="reg_btn" runat="server" Text="register" />
</td>
</tr>
</table>
</div>
</div>
</div>
</section>
I am writing a program to insert value in database on button click event. That program is using VB.NET. If I run the application, when I click the button, it does not fire a click event of the button. Help me to correct. Here's my code:
Imports System.Data
Imports System.IO
Imports System.Data.SqlClient
Partial Class main
Inherits System.Web.UI.Page
Dim command As SqlCommand
Dim da As SqlDataAdapter
Dim ds As New DataSet
Dim i As Integer
Dim str As String = ConfigurationManager.ConnectionStrings("con").ConnectionString
Dim con As New SqlConnection(str)
'Protected Sub REGISTER_Click(sender As Object, e As EventArgs) Handles REGISTER.Click
'End Sub
Protected Sub Login_Click(sender As Object, e As EventArgs) Handles Login.Click
If (Page.IsValid) Then
Dim intusercount As SqlDataReader
Dim a, b As String
Using connection As New SqlConnection("Data Source=DESKTOP-LHSLB8R;Initial Catalog=temp_db;Integrated Security=True")
Using command As New SqlCommand("SELECT [v_id],[v_name] FROM [vendor_mstr] WHERE [v_user]=#Username AND [v_pass]=#Password", connection)
command.Parameters.Add("#Username", Data.SqlDbType.VarChar, 50).Value = username_txt.Text
command.Parameters.Add("#Password", Data.SqlDbType.VarChar, 50).Value = password_txt.Text
connection.Open()
intusercount = command.ExecuteReader
'Dim red As SqlDataReader =command.ExecuteReader
If intusercount.HasRows Then
While intusercount.Read()
MsgBox(intusercount.Item(0))
a = intusercount.Item(0)
b = intusercount.Item(1)
End While
Session("uid") = a
Session("user") = b
Response.Redirect("v_h.aspx")
Else
MsgBox("invalid username or password")
End If
connection.Close()
End Using
End Using
End If
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Session.Remove("uid")
Session.Remove("user")
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles reg_btn.Click
MsgBox("click")
Try
con.Open()
command = New SqlCommand("INSERT INTO vendor_mstr(v_name,v_area,v_contact,v_email,v_loc,v_user,v_pass,v_city,v_state)VALUES('" & vreg_name_txt.Text & "','" & vreg_area_txt.Text & "','" & vreg_con_txt.Text & "','" & vreg_email_txt.Text & "','" & vreg_loc_dl.SelectedValue & "','" & v_user_txt.Text & "','" & v_pass_txt.Text & "','" & vreg_city_dl.SelectedValue & "','" & vreg_state_dl.SelectedValue & "')")
command.Connection = con
command.ExecuteNonQuery()
con.Close()
MsgBox("registered :)")
Catch ex As Exception
MsgBox("not registered :(")
End Try
End Sub
End Class
change This
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles reg_btn.Click
with this :
Protected Sub reg_btn_Click(sender As Object, e As EventArgs) Handles reg_btn.Click
I developed the compose message from email,
I attaching the files then i have selecting the combo box item its deleting the attachment files.
Here my ASP Code:
<asp:UpdatePanel ID="updatepanel" runat="server">
<ContentTemplate>
<tr>
<td valign="top">
<asp:Label ID="lblfile_name" runat="server" CssClass="labels">Upload File</asp:Label>
</td>
<td>
<div style="overflow-y: scroll; z-index: auto; height: 60px;">
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="multi" Visible="true" />
</div>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
<tr>
<td>
<telerik:RadComboBox EmptyMessage="----- Select -----" ID="cboTemplate" runat="server" Skin="WebBlue" AutoPostBack="true">
</telerik:RadComboBox>
</td>
</tr>
Here VB. NET CODE
Private Sub cboTemplate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboTemplate.SelectedIndexChanged
If cboTemplate.SelectedValue = "--Select--" Then
lblErrMsg.Text = objcmnfunctions.GetErrMsg("B2B_WAR_110")
SetFocus(anc_err)
Exit Sub
End If
objdbconn.OpenConn()
msSQL = " Select mailtemplate_gid, template_name, template_content " & _
" from crm_trn_tmailtemplates " & _
" where mailtemplate_gid = '" & cboTemplate.SelectedValue & "'"
objOdbcDataReader = objdbconn.GetDataReader(msSQL)
If objOdbcDataReader.HasRows = True Then
objOdbcDataReader.Read()
radmailcontent.Content = objOdbcDataReader.Item("template_content").ToString
End If
objOdbcDataReader.Close()
objdbconn.CloseConn()
End Sub
Store the value of FileUpload1 to Session Object
If Session("FileUpload1") Is Nothing AndAlso FileUpload1.HasFile Then
Session("FileUpload1") = FileUpload1
ElseIf Session("FileUpload1") IsNot Nothing AndAlso (Not FileUpload1.HasFile) Then
FileUpload1 = DirectCast(Session("FileUpload1"), FileUpload)
ElseIf FileUpload1.HasFile Then
Session("FileUpload1") = FileUpload1
End If
The reason the dropdown is clearing the value from Upload is because it is set to AutoPostBack="true"
I'm trying - quite unsuccessfully - to access a button inside a repeater control. I have a repeater set up on a page that displays movies that are currently showing in cinemas. I have created two buttons and added them to the repeater - one for trailer and another for review. For the review I want to link to another page which will have another repeater with paging enabled. When a users clicks the review button they should be brought to a page that shows only the reviews for that specific movie. This is that code I have:
MARKUP:
The repeater:
<asp:Repeater ID="movies" runat="server">
<ItemTemplate>
<table width="641px">
<tr>
<td>
<span style="font-weight:bold;font-size:16px;">
<%# Container.DataItem("MovieTitle")%>
</span>
</td>
<td>
<span style="float:right;">
<asp:Image ID="Image1" runat="server" ImageUrl = '<%# Eval("Total")%>' style="width:80px;height:14px;"/>
</span>
</td>
</tr>
<tr>
<td colspan="2">
<hr style="height:1px;border-bottom:none;color:#e3e3e3;"/>
</td>
</tr>
</table>
<table width="641px">
<tr>
<td>
<asp:Image ID="Image2" runat="server" ImageUrl = '<%# Eval("MovieImageFileName")%>' style="width:180px;height:108px;border:1px solid #e3e3e3;"/>
</td>
<td style="vertical-align:top;">
<%# Container.DataItem("Synopsis")%>
</td>
</tr>
</table>
<table width="641px">
<tr>
<td>
<span style="float:right">
<asp:Button ID="btnTrailer" runat="server" Text="Trailer" BackColor="#FF9900" ForeColor="White" />
<asp:Button ID="btnReview" runat="server" Text="Review" BackColor="#FF9900" ForeColor="White" CommandName="Review" />
</span>
</td>
</tr>
<tr>
<td>
<hr style="height:1px;border-bottom:none;color:#e3e3e3;"/>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
CodeBehind:
Dim movie_title As String
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim myConn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim dr, aDataReader As OleDbDataReader
Dim query, movieID As String
movie_title = Request.QueryString("id")
myConn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = " & _
Server.MapPath("/App_Data/MovieBoard.accdb"))
myConn.Open()
Dim sqlQuery = "Select movieID From Movies"
Dim aCmd = New OleDbCommand(sqlQuery, myConn)
aDataReader = aCmd.ExecuteReader()
If aDataReader.Read() = True Then
movieID = aDataReader(0)
Else
movieID = "0"
End If
query = ("Select MovieTitle, Genre, Synopsis, Starring, Total, Director, MovieImageFileName From Movies, MovieReviews, MReviewRatings WHERE Movies.MovieID = MovieReviews.MovieID AND MovieReviews.MReviewID = MReviewRatings.MReviewID AND ReviewerTypeID = 1")
cmd = New OleDbCommand(query, myConn)
dr = cmd.ExecuteReader()
movies.DataSource = dr
movies.DataBind()
End Sub
Protected Sub movies_ItemCommand(source As Object, e As RepeaterCommandEventArgs) Handles movies.ItemCommand
If e.CommandName = "Review" Then
Response.Redirect("testingreviews.aspx?id = '" & movie_title)
End If
End Sub
When I run page the page displays but when I click the review button I get the following error:
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/>
in configuration or <%# Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or
callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.
RegisterForEventValidation method in order to register the postback or callback data for validation.
Anyone any ideas on what I am doing wrong? I am very new to asp.net.
If you want to access a button use the event ItemCreated or maybe its ItemDataBound.
Handles movies.ItemCreated
In that event you can then refeer to the button using FindControl,
Something like this
Sub Movies_ItemDataBound(Sender As Object, e As RepeaterItemEventArgs) Handles movies.ItemDataBound
Dim Btn As Button = CType(e.Item.FindControl("ButtonName"),Button)
End Sub
I have my DataList in ASP.NET 3.5 Access 2003 DataSource. I want to create paging for a DataList control using VB.
DataList lacks functionality of pagging like in GridView but its possible to implement pagging functionality for DataList.
Here i have done pagging using PagedDataSource which enclose the paging related properties of a data-bound control, that allow it to perform the pagging. More details about PagedDataSource
Inline code
<div>
<asp:DataList ID="dataListStudent" runat="server">
<ItemTemplate>
<table cellpadding="10">
<tr>
<td nowrap="nowrap">
<b>Student id</b>
</td>
<td nowrap="nowrap">
<b>First name</b>
</td>
<td nowrap="nowrap">
<b>Last name</b>
</td>
<td>
<b>City</b>
</td>
</tr>
<hr />
<tr>
<td nowrap="nowrap">
<%# Eval("StudentID") %>
</td>
<td nowrap="nowrap">
<%# Eval("FirstName") %>
</td>
<td nowrap="nowrap">
<%# Eval("LastName") %>
</td>
<td nowrap="nowrap">
<%# Eval("City") %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<br />
<table border="0" width="410">
<tr>
<td align="left">
<asp:LinkButton ID="lbPrev" runat="server">
Prev
</asp:LinkButton>
</td>
<td align="right">
<asp:LinkButton ID="lbNext" runat="server">
Next
</asp:LinkButton>
</td>
</tr>
</table>
</div>
Code-behind
Imports System.Data
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Dim pageds As New PagedDataSource()
Public Property CurrentPage() As Integer
Get
If Me.ViewState("CurrentPage") Is Nothing Then
Return 0
Else
Return Convert.ToInt16(Me.ViewState("CurrentPage").ToString())
End If
End Get
Set(ByVal value As Integer)
Me.ViewState("CurrentPage") = value
End Set
End Property
Sub bindDataList()
Dim sql As String
sql = "SELECT * FROM STUDENTS"
Dim da As New OleDbDataAdapter(sql, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Course.mdb")
Dim dt = New DataTable()
da.Fill(dt)
Try
pageds.DataSource = dt.DefaultView
pageds.AllowPaging = True
pageds.PageSize = 3
pageds.CurrentPageIndex = CurrentPage
lbNext.Enabled = Not pageds.IsLastPage
lbPrev.Enabled = Not pageds.IsFirstPage
dataListStudent.DataSource = pageds
dataListStudent.DataBind()
Catch ex As Exception
Throw ex
End Try
End Sub
Protected Sub lbPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbPrev.Click
currentPage -= 1
bindDataList()
End Sub
Protected Sub lbNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbNext.Click
currentPage += 1
bindDataList()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
bindDataList()
End If
End Sub
End Class
Your connection string, Column names might be different you might want different layout of DataList feel free to fiddle with it. Hopefully it will help you to solve the problem.
I am using nested repeaters with Dataset (not using Datatable) to retrieve information by passing parameters. So far I have bind the two repeaters clearly and everything is working fine.
Here the list of messages created by each user datawise(parameter passed) will be displayed, and there could be more than 50 messages created by each user daily. So now I want to do custom paging for each user.
But I am unable to proceed further, as the next, previous, back, first links are placed inside the child repeaters footer template and I couldn't access these links even by findcontrol method.
Example:
User1
No Msg Code
1 abcd Cl-6
2 some Cl-4
3 swedf Cl-3
4 sddf Cl-1
1,2,3,4,5 (Paging)
User2
No Msg Code
1 dgfv Cl-96
2 abcd Cl-4
3 sjuc Cl-31
4 liot Cl-1
1,2,3,4,5 (Paging)
In this ways goes for every user:
Public Sub CreateNestedRepeater()
Dim strSql_1 As String, strsql_2 As String
Dim strCon_1 As New SqlConnection
Dim strCon_2 As New SqlConnection
Dim ds As New DataSet()
frmDate = AMS.convertmmddyy(txtFromDate.Text)
toDate = AMS.convertmmddyy(txtToDate.Text)
strCon_1 = New SqlConnection(ConfigurationManager.ConnectionStrings("connectionString").ConnectionString)
strSql_1 = "select User_Login, User_Id from V_mst_UserMaster Where User_Flag = 1 and User_Type='CO'"
Dim daCust As New SqlDataAdapter(strSql_1, strCon_1)
daCust.Fill(ds, "RptCoord_Name")
WhereClause1 = "where MsgHdr_Id NOT IN (Select a.MsgHdr_Id from V_AMS_GetSentMsg as a Join V_AMS_GetSentMsg as b " _
& "on a.MsgHdr_Id = b.MsgHdr_PrevMsgId) and MsgHdr_Date >= '" & frmDate & "' and MsgHdr_Date <= '" & toDate & _
"'AND MsgHdr_MsgFlag='I' and MsgHdr_AckReq <> 'N'"
OrderBy = "order by MsgHdr_Date asc"
strCon_2 = New SqlConnection(ConfigurationManager.ConnectionStrings("conn_Ind_AKK_TRAN").ConnectionString)
strsql_2 = "select User_Login,MsgHdr_Date, Client_Code, MsgHdr_RefNo, MsgType_Name, MsgHdr_Subject " _
& " from V_AMS_GetSentMsg " & WhereClause1 & OrderBy
Dim daOrders As New SqlDataAdapter(strsql_2, strCon_2)
daOrders.Fill(ds, "RptCd_Record")
Dim rel As New DataRelation("CrdRelation", ds.Tables("RptCoord_Name").Columns("User_Login"), ds.Tables("RptCd_Record").Columns("User_Login"), False)
ds.Relations.Add(rel)
rel.Nested = True
Rep1.DataSource = ds.Tables("RptCoord_Name").DefaultView
Rep1.DataBind()
strCon_1.Close()
strCon_2.Close()
End Sub
Protected Sub Rep1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Rep1.ItemCommand
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
DirectCast(e.Item.FindControl("Rep2"), Repeater).DataSource = DirectCast(e.Item.DataItem, DataRowView).CreateChildView("CrdRelation")
DirectCast(e.Item.FindControl("Rep2"), Repeater).DataBind()
End If
End Sub
Protected Sub Pagging(ByVal index As Integer)
Dim PDS As New PagedDataSource
PDS.DataSource = ds.Tables("RptCoord_Name").DefaultView
PDS.CurrentPageIndex = index
PDS.AllowPaging = True
PDS.PageSize = 4
Dim rep2 As Repeater = CType(e
rep2.DataSource = PDS
Rep2.DataBind()
Dim ddl As DropDownList = DirectCast(rep2.Controls(rep2.Controls.Count - 1).FindControl("PageCount"), DropDownList)
If ddl IsNot Nothing Then
For i As Integer = 1 To PDS.PageCount - 1
ddl.Items.Add(i.ToString())
Next
End If
End Sub
Public Sub PageIndex(ByVal sender As Object, ByVal e As EventArgs)
Dim ddl As DropDownList = DirectCast(rep2.Controls(rep2.Controls.Count - 1).FindControl("PageCount"), DropDownList)
Pagging(Integer.Parse(ddl.SelectedItem.Text) - 1)
End Sub
XML:
<asp:Repeater id="Rep1" runat="server" OnItemCommand="Rep1_ItemCommand" EnableViewState = "false" >
<ItemTemplate>
<table width="100%" border="0.8" cellpadding="0" cellspacing="0" CssClass="bodytext" >
<tr><td align="center" class="RepHeader" >
Incoming Messages - Pending Ack for
<%#getUser(DataBinder.Eval(Container.DataItem, "User_Login"))%> from <%= txtFromDate.Text %>
to <%=txtToDate.Text%>
<%-- OnItemDataBound="Rep2_ItemDataBound" --%>
<asp:Repeater id="Rep2" runat="server" datasource='<%#(Container.DataItem).Row.GetChildRows("CrdRelation") %>' >
<HeaderTemplate>
<table border="1" width="100%" >
<tr class="RepHeader" >
<td>Msg Date</td><td>CL Code</td><td>INCRefNo</td><td>Contents</td><td>Subject</td></tr></HeaderTemplate><ItemTemplate>
<tr class="RrpList">
<td><%#getdate(CType(Container.DataItem, System.Data.DataRow)("MsgHdr_Date"))%> </td>
<td><%#CType(Container.DataItem, System.Data.DataRow)("Client_Code")%> </td>
<td><asp:LinkButton ID="lnkRef" runat="server"></asp:LinkButton>
<a id="hrefRefNo" runat="server" href="#" class="Link" >
<%#CType(Container.DataItem, System.Data.DataRow)("MsgHdr_RefNo")%></a></td>
<td><%#CType(Container.DataItem, System.Data.DataRow)("MsgType_Name")%> </td>
<td><%#CType(Container.DataItem, System.Data.DataRow)("MsgHdr_Subject")%> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
<%--Starts Here - (Paging for Pending Nested Repeaters) --%>
<tr align="center" class = "RepHeader">
<td colspan="5">
<asp:LinkButton ID="lnkFirst" runat="server" ForeColor="Black" Text="First" >
</asp:LinkButton>
<asp:LinkButton ID="lnkPrevious" runat="server" ForeColor="Black" Text="Previous" >
</asp:LinkButton> Now Showing Page
<asp:DropDownList ID="ddlpageNumbers" runat="server" AutoPostBack="true" >
</asp:DropDownList> of <asp:Label ID="lblTotalPages" runat="server"> </asp:Label>
Pages.
<asp:LinkButton ID="lnkNext" runat="server" ForeColor="Black" Text="Next" >
</asp:LinkButton>
<asp:LinkButton ID="lnkLast" runat="server" ForeColor="Black" Text="Last" >
</asp:LinkButton>
</td> </tr>
<%--Ends Here (Paging for Pending Nested Repeaters)--%>
</td></tr>
<br />
</table>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
<SeparatorTemplate><br /><br /></SeparatorTemplate>
</asp:Repeater>
I couldn't understand how to do paging.
You shroud read about it:
http://idunno.org/archive/2004/10/30/145.aspx
http://support.microsoft.com/kb/306154