ASP / ASP.net postback problems With VB.net 2010 - asp.net

I'm working on a web app and i have the vb.net code working in the web form to only load setting in my controls once. but I'm using a google map control and every time my timer runs that control reloads it setting and wipes out any data i push in. i think i need some help in the asp.net/html side to stop on post back reloading the control.
here is my asp.net/html code.
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width:100%;">
<tr>
<td style="width: 668px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<artem:GoogleMap ID="GoogleMap1" runat="server"
DefaultAddress="999 main st, new york NY, 10541"
EnableMapTypeControl="True" EnableOverviewMapControl="False"
EnableReverseGeocoding="True" EnableStreetViewControl="False" MapType="Roadmap"
MaxZoom="25" MinZoom="12" ShowTraffic="False" Zoom="18" Height="380px"
Width="550px" Key="13123123132132132132132123" >
</artem:GoogleMap>
<br />
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 668px">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<asp:Timer ID="tmUpdateAlarms" runat="server" Enabled="False" Interval="30000">
</asp:Timer>
</td>
</tr>
</table>
My Timer Code
Protected Sub tmUpdateAlarms_Tick(sender As Object, e As System.EventArgs) Handles tmUpdateAlarms.Tick
tmUpdateAlarms.Enabled = False
Try
Dim lqFireFighterconnect As New lqFireFighterConnectDataContext
Dim lqGetAlarms As New lqAlarmAndGoDataContext
Dim getDeptGUID = From r In lqFireFighterconnect.tbDeptToPublics
Where r.PublicGUID = Request.QueryString("PUBGUID")
Select r
If getDeptGUID.Count = 0 Then
Exit Sub
End If
For Each foundGUID In getDeptGUID.Take(1)
gotDeptGUID = foundGUID.DeptGUID
Next
Dim GetAlarms = From r In lqGetAlarms.AlarmDrops
Where r.DeptGUID = gotDeptGUID
Order By r.TimeDate Descending
Select r
If GetAlarms.Count = 0 Then
Exit Sub
End If
Dim myCBTable As New DataTable()
With myCBTable.Columns
.Add("DateTime", GetType(String))
.Add("Address", GetType(String))
.Add("AlarmType", GetType(String))
.Add("CrossStreet", GetType(String))
.Add("Status", GetType(String)) '<<<< change the type of this column to what you actually need instead of integer.
End With
For Each FoundAlarm In GetAlarms.Take(1)
If Not GridView1.Rows(0).Cells(1).Text.ToString = FoundAlarm.AlarmAddress Then
For Each updateAlarm In GetAlarms.Take(3)
myCBTable.Rows.Add(updateAlarm.TimeDate.ToString, updateAlarm.AlarmAddress, updateAlarm.AlarmType, updateAlarm.AlarmCrossStreets, updateAlarm.AlarmStatus)
Next
With GridView1
.DataSource = myCBTable
.DataBind()
End With
Dim objmar As New Artem.Google.UI.Marker
objmar.Address = GridView1.Rows(0).Cells(1).Text.ToString
'objmar.Animation = Artem.Google.UI.MarkerAnimation.Drop
objmar.Visible = True
objmar.Title = GridView1.Rows(0).Cells(1).Text.ToString
objmar.Icon = "/Images/fire_c.png"
GoogleMap1.Markers.Add(objmar)
objmar = Nothing
GoogleMap1.Address = GridView1.Rows(0).Cells(1).Text.ToString
End If
Next
' LoadHydrants()
Catch ex As Exception
End Try
tmUpdateAlarms.Enabled = True
End Sub

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<artem:GoogleMap ID="GoogleMap1" runat="server"
DefaultAddress="999 main st, New York ny, 10541"
EnableMapTypeControl="True" EnableOverviewMapControl="False"
EnableReverseGeocoding="True" EnableStreetViewControl="False" MapType="Roadmap"
MaxZoom="25" MinZoom="12" ShowTraffic="False" Zoom="18" Height="380px"
Width="550px" Key="1231231231231231231231321231313213" >
</artem:GoogleMap>
</ContentTemplate>
</asp:UpdatePanel>

Related

Dynamic page creation from db at run time in asp.net

I'm making E-Commerce website. Under that I want to show particular product details. From query string I can do that but that is not seo friendly so I need to make product name in url(from db) instead of using querystring. I tried following code but it is not working for me.
Error - The resource could not be Found
Global.asax
<%# Application Language="VB" %>
<%# Import Namespace="System.Web.Optimization" %>
<%# Import Namespace="System.Web.Routing" %>
<script runat="server">
Sub Application_Start(sender As Object, e As EventArgs)
RouteConfig.RegisterRoutes(RouteTable.Routes)
BundleConfig.RegisterBundles(BundleTable.Bundles)
End Sub
Private Shared Sub RegisterRoutes(routes As RouteCollection)
routes.MapPageRoute("product-detail", "{product_name}.aspx", "product-detail.aspx")
End Sub
</script>
product-detail.aspx (Dynamic Page)
Private Sub product_detail_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim pageName As String = Me.Page.RouteData.Values("product_name").ToString()
End If
End Sub
shop.aspx (used listview control to display list of products)
<asp:ListView ID="products" runat="server" DataKeyNames="ID">
<ItemTemplate>
<asp:HyperLink ID="productID" runat="server" NavigateUrl='<%# Eval("product_name", "~/{0}") %>' CssClass="product-link">
<!--blocks-starts--><div class="blocks blocks-shop">
<asp:Image ID="readyStock" runat="server" ImageUrl="images/common/ready_stock_tag.png" Visible="false" CssClass="tag" />
<asp:Label ID="checkReadyStock" runat="server" Visible="false"></asp:Label>
<div class="block-img">
<img src='<%# Eval("image") %>' runat="server" id="proImg" />
</div>
<div class="block-content">
<span class="sku" style="font-size:0.6em !important">Item No. <asp:Label ID="skuID" runat="server" Text='<%# Eval("sku") %>'></asp:Label></span>
<h3>
<asp:Label ID="prodName" runat="server" Text='<%# Eval("product_name") %>'></asp:Label></h3>
<p><strong>
<asp:Label ID="priceRange" runat="server" Text='<%# Eval("price_range") %>'></asp:Label></strong></p>
</div>
</div><!--blocks-ends-->
</asp:HyperLink>
</ItemTemplate>
<LayoutTemplate>
<div id="itemPlaceholderContainer" runat="server" style="">
<div runat="server" id="itemPlaceholder" />
</div>
</LayoutTemplate>
</asp:ListView>
shop.aspx.vb
Private Sub shop_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Try
Dim str As String = "select * from products where status = 'active'"
Dim cmd As New MySqlCommand(str, con)
con.Open()
Dim da As New MySqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
products.DataSource = dt
products.DataBind()
con.Close()
Catch ex As Exception
Response.Write(ex)
End Try
End If
End Sub

Add data to gridview, from textbox, on button click

I am working on an aspx site that lets an admin-level user fill out a form with potential member data. Once the form is filled out, the user will click submit and the data will go off to different tables. One part of the form that is stumping me involves filling out three textboxes (txtFirstName, txtLastName, txtGrade). I have a button (btnAddStudent), that, when clicked, should add the information from the textboxes to a table-like display area. I am trying to use a gridview, but there is nothing to bind it to. There is no memberID number to load a blank record from the Student table (which is a many-to-one relation to Member table). The member record is what this form is creating, and the student data will be added to the Student table when the Submit button is clicked.
I am currently working with the code found in the reply here. But when I click the "Add Student" button, I get a new blank row, but my textbox values are not inputted in the gridview.
Can this work, or do I need to look at using a table and adding rows of textboxes dynamically?
Here is relevant source code:
<tr>
<td class="style8">
<asp:Label ID="Label18" runat="server" Text="Chidren:" Font-Bold="True" Font- Underline="True" Font-Names="Tahoma"></asp:Label>
</td>
</tr>
<tr>
<td class="style8">
<asp:Label ID="Label19" runat="server" Text="First Name:"></asp:Label>
</td>
<td class="style7">
<asp:TextBox ID="txtChildFirstName" runat="server" CssClass="textbox"></asp:TextBox>
</td>
<td class="">
<asp:Label ID="Label20" runat="server" Text="Last Name:"></asp:Label>
</td>
<td class="style6">
<asp:TextBox ID="txtChildLastName" runat="server" CssClass="textbox"></asp:TextBox>
</td>
<td class="style5" align="right">
<asp:Label ID="Label21" runat="server" Text="Grade:"></asp:Label>
</td>
<td class="style4">
<asp:TextBox ID="txtGrade" runat="server" Width="52px" CssClass="textbox"></asp:TextBox>
</td>
<td>
<asp:Button ID="btnAddChild" runat="server" Text="Add Child" OnClick="btnAddChild_Click" />
</td>
</tr>
<tr>
<td valign="top" class="style8">
<asp:Label ID="Label22" runat="server" Text="Student List:"></asp:Label>
</td>
<td colspan="3">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="gvStudentList" runat="server" AutoGenerateColumns="False"
PageSize="5" Height="42px">
<AlternatingRowStyle BackColor="#E0E0E0" />
<Columns>
<asp:BoundField AccessibleHeaderText="FirstName" HeaderText="First Name" />
<asp:BoundField AccessibleHeaderText="LastName" HeaderText="Last Name" />
<asp:BoundField AccessibleHeaderText="Grade" HeaderText="Grade" />
</Columns>
<HeaderStyle BackColor="#CCCCCC" Height="25px" />
<RowStyle Height="22px" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
And the Code Behind:
'A method that will BIND the GridView based on the TextBox
'values and retain its values on post backs.
Private Sub BindGrid(rowcount As Integer)
Dim dt As New DataTable()
Dim dr As DataRow
dt.Columns.Add(New System.Data.DataColumn("FirstName", GetType([String])))
dt.Columns.Add(New System.Data.DataColumn("LastName", GetType([String])))
dt.Columns.Add(New System.Data.DataColumn("Grade", GetType([String])))
If ViewState("CurrentData") IsNot Nothing Then
For i As Integer = 0 To rowcount
dt = DirectCast(ViewState("CurrentData"), DataTable)
If dt.Rows.Count > 0 Then
dr = dt.NewRow()
dr(0) = dt.Rows(0)(0).ToString()
End If
Next
dr = dt.NewRow()
dr(0) = txtChildFirstName.Text
dr(1) = txtChildLastName.Text
dr(2) = txtGrade.Text
dt.Rows.Add(dr)
Else
dr = dt.NewRow()
dr(0) = txtChildFirstName.Text
dr(1) = txtChildLastName.Text
dr(2) = txtGrade.Text
dt.Rows.Add(dr)
End If
' If ViewState has a data then use the value as the DataSource
If ViewState("CurrentData") IsNot Nothing Then
gvStudentList.DataSource = DirectCast(ViewState("CurrentData"), DataTable)
gvStudentList.DataBind()
Else
' Bind GridView with the initial data assocaited in the DataTable
gvStudentList.DataSource = dt
gvStudentList.DataBind()
End If
' Store the DataTable in ViewState to retain the values
ViewState("CurrentData") = dt
End Sub
Protected Sub btnAddChild_Click(sender As Object, e As EventArgs) Handles btnAddChild.Click
' Check if the ViewState has a data assoiciated within it. If
If ViewState("CurrentData") IsNot Nothing Then
Dim dt As DataTable = DirectCast(ViewState("CurrentData"), DataTable)
Dim count As Integer = dt.Rows.Count
BindGrid(count)
Else
BindGrid(1)
End If
txtChildFirstName.Text = String.Empty
txtChildLastName.Text = String.Empty
txtGrade.Text = String.Empty
txtChildFirstName.Focus()
End Sub
With "BindGrid()" being called in the Page_Load event. (And yes, I have ScriptManager)
Try to use
Session("CurrentData") = dt on your BindGrid()
Then Create Method that just refreshes the grid after postback:
Private Sub RefreshGrid()
{
If ViewState("CurrentData") IsNot Nothing Then
gvStudentList.DataSource = DirectCast(Session("CurrentData"), DataTable)
gvStudentList.DataBind()
Else
gvStudentList.DataSource = null;
gvStudentList.DataBind()
EndIf
}
On your page load just call:
If IsPostBack Then
Return
End If
RefreshGrid()
Regards

Page_Load not update after click the button

I have a simple ASP.NET page:
sub Page_Load
//Get data form databse and show it
end sub
sud deletsome(Source As Object, e As EventArgs)
//delete one record when user click on submit button
end sub
When I click the button, the page reload, all the data have no change, I must re-enter the page again, the record I have delete disappear.
Can you show me why?
The full code here:
<%# Import Namespace="System.Data.OleDb" %>
<script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;data source=" & server.mappath("/data/test.accdb"))
dbconn.Open()
sql="SELECT * FROM [user]"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
dbread.Close()
dbconn.Close()
end sub
sub deletesome(Source As Object, e As EventArgs)
dim dbconn,sql,dbcomm
dbconn=New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;data source=" & server.mappath("/data/test.accdb"))
dbconn.Open()
sql="DELETE FROM [user]WHERE id = #ID"
dbcomm=New OleDbCommand(sql,dbconn)
dbcomm.Parameters.AddWithValue("ID", tb1.Text)
dbcomm.ExecuteNonQuery()
end sub
</script>
<html>
<body>
<form runat="server">
<asp:TextBox id="tb1" runat="server" />
<asp:Button id="b1" Text="Submit" runat="server" OnClick="deletesome" />
<asp:Repeater id="customers" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<th>ID</th>
<th>Address</th>
<th>City</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("id")%> </td>
<td><%#Container.DataItem("username")%> </td>
<td><%#Container.DataItem("userphone")%> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
<hr />
</body>
</html>
In asp page life cycle, page load happens before the button click (I know, it's kind of strange). The easiest work around is to place your code in the page "PreRender" event.
Use if(!IsPostBack) on page load.
You have not added the !IsPostBack condition in your page load event. When you click the button your page's load event is first called before the click event handler and it will reload the data again. That's the issue.
It should be like...
sub Page_Load
IF(!IsPostBack) ' This condition will be true when the page loads the first time
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;data source=" & server.mappath("/data/test.accdb"))
dbconn.Open()
sql="SELECT * FROM [user]"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
dbread.Close()
dbconn.Close()
EndIf
end sub
try this
<%# Import Namespace="System.Data.OleDb" %>
<script runat="server">
sub Page_Load
If Page.IsPostBack = False Then
LoadData()
end sub
sub deletesome(Source As Object, e As EventArgs)
dim dbconn,sql,dbcomm
dbconn=New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;data source=" & server.mappath("/data/test.accdb"))
dbconn.Open()
sql="DELETE FROM [user]WHERE id = #ID"
dbcomm=New OleDbCommand(sql,dbconn)
dbcomm.Parameters.AddWithValue("ID", tb1.Text)
dbcomm.ExecuteNonQuery()
LoadData()
end sub
sub LoadData
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;data source=" & server.mappath("/data/test.accdb"))
dbconn.Open()
sql="SELECT * FROM [user]"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
dbread.Close()
dbconn.Close()
end sub
</script>
<html>
<body>
<form runat="server">
<asp:TextBox id="tb1" runat="server" />
<asp:Button id="b1" Text="Submit" runat="server" OnClick="deletesome" />
<asp:Repeater id="customers" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<th>ID</th>
<th>Address</th>
<th>City</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("id")%> </td>
<td><%#Container.DataItem("username")%> </td>
<td><%#Container.DataItem("userphone")%> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
<hr />
</body>
</html>

Custom Paging in Child (Inner) Nested Repeaters

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

How to add asyncPostBackTrigger to Template column, Item Template, Button in DataGrid

I need to add a trigger for two buttons in DataGrid Template columns. I have found a couple postings saying to put the code in the code-behind using the UniqueID.
Something isn't right with my logic (or maybe it isn't in the right place). I am getting "Object reference not set to an instance of an object" error when I run it.
I am getting this on my "gridSelectTrigger.ControlID = btnSessionSelect.UniqueID" statement.
Does this logic need to be in an "ItemDataBound" event? Or is my logic wrong?
<%# Page Title="Admin Session Folders" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="AdminAddEditReleaseAndFiles.aspx.vb" Inherits="AdminAddEditReleaseAndFiles" Theme="Standard" %>
<asp:Panel ID="pnlEditTopic" runat="server" CssClass="modalPopupEditTopic" Style="display: none;" >
<table cellspacing="0" class="borderTable0" width="100%" style="">
<tr style="height:4px">
<td colspan="6" align="center">
<asp:ImageButton ID="btnAddTopic" runat="server" AlternateText="Add Topic"
ImageUrl="~/App_Themes/Common/images/BtnApply.jpg" Height="28px">
</asp:ImageButton>
<asp:ImageButton ID="btnUpdateTopic" runat="server" AlternateText="Update Topic"
ImageUrl="~/App_Themes/Common/images/BtnApply.jpg" Height="28px">
</asp:ImageButton>
<asp:ImageButton ID="btnDeleteTopic" runat="server" AlternateText="Delete Topic"
ImageUrl="~/App_Themes/Common/images/BtnDelete.jpg" Height="28px">
</asp:ImageButton>
<asp:ImageButton ID="btnEditTopicClose" runat="server" AlternateText="Close Edit Topic Popup"
ImageUrl="~/App_Themes/Common/images/BtnCancel.jpg" Height="28px">
</asp:ImageButton>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not (IsPostBack) Then
Dim MainContent As ContentPlaceHolder = TryCast(Page.Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
Dim UpdatePanelSessions As UpdatePanel = TryCast(MainContent.FindControl("UpdatePanelSessions"), UpdatePanel)
Dim btnSessionSelect As Button = TryCast(UpdatePanelSessions.FindControl("btnSessionSelect"), Button)
Dim btnSessionDetail As Button = TryCast(UpdatePanelSessions.FindControl("btnSessionDetail"), Button)
Dim gridSelectTrigger As AsyncPostBackTrigger = New AsyncPostBackTrigger
Dim gridDetailTrigger As AsyncPostBackTrigger = New AsyncPostBackTrigger
gridSelectTrigger.ControlID = btnSessionSelect.UniqueID
gridSelectTrigger.EventName = "Click"
UpdatePanelSessions.Triggers.Add(gridSelectTrigger)
gridDetailTrigger.ControlID = btnSessionDetail.UniqueID
gridDetailTrigger.EventName = "Click"
UpdatePanelSessions.Triggers.Add(gridDetailTrigger)
End If
End Sub
Thank you,
James
Got it. The update panel needed children as triggers set to true.

Resources