Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Data.SqlClient
Imports System.Data.OleDb
Partial Class Default8
Inherits System.Web.UI.Page
Dim conn As New ConnectDB
Dim converd_date As New date_string
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Binddashboard()
End Sub
Private Sub Binddashboard()
Dim sqlCommand As String
sqlCommand = "SELECT *,convert(varchar,UserStatusDate,120) con_date FROM ORDERS,USERS WHERE USERS.UserId = ORDERS.UserId and OrderStatus not in ('Waiting for Approved','Cancel')"
Dim dtTemp As New DataTable
dtTemp = conn.FillDataSet(sqlCommand)
Griddashboard.DataSource = dtTemp
Griddashboard.DataBind()
End Sub
Protected Sub ShowPageCommand(ByVal s As Object, ByVal e As GridViewPageEventArgs)
Dim newPageIndex As Integer = e.NewPageIndex
Griddashboard.PageIndex = newPageIndex
Binddashboard()
End Sub
Protected Sub btnchg_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim btn As New Button
btn = CType(sender, Button)
Dim orderid As String
orderid = Griddashboard.DataKeys(CType(btn.NamingContainer, GridViewRow).RowIndex).Values("OrderId")
End Sub
Protected Sub gridOffersPush_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Griddashboard.RowCreated
UpdatePanel1.Update()
Dim cmdShowOfferDetailsDoc, btn1 As Button
cmdShowOfferDetailsDoc = CType(e.Row.FindControl("btnchg"), Button)
btn1 = CType(e.Row.FindControl("Button1"), Button)
Dim objSM As ScriptManager
objSM = Me.Page.FindControl("ScriptManager1")
If Not objSM Is Nothing And Not cmdShowOfferDetailsDoc Is Nothing Then
objSM.RegisterPostBackControl(cmdShowOfferDetailsDoc)
objSM.RegisterPostBackControl(btn1)
End If
End Sub
End Class
Tag : .NET, Ms SQL Server 2005, Ajax, Web (ASP.NET), VB.NET
<%@ Master Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public Property Offset() As Integer
Get
If ViewState("Offset") Is Nothing Then
Return 0
Else : Return ViewState("Offset")
End If
End Get
Set(ByVal value As Integer)
ViewState("Offset") = value
End Set
End Property
Protected Sub MasterButton_Click(ByVal Sender As Object, ByVal E As EventArgs)
Select Case Sender.ID
Case "IncrementButton"
Me.Offset = Me.Offset + 1
Case "DecrementButton"
Me.Offset = Me.Offset - 1
End Select
Dim upl As UpdatePanel
upl = ContentPlaceHolder1.FindControl("UpdatePanel1")
upl.Update()
Dim cal As Calendar
cal = ContentPlaceHolder1.FindControl("Calendar1")
Dim newDateTime As DateTime
newDateTime = DateTime.Today.Add(New TimeSpan(Offset, 0, 0, 0))
cal.SelectedDate = newDateTime
End Sub
Protected Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
ScriptManager1.RegisterAsyncPostBackControl(DecrementButton)
ScriptManager1.RegisterAsyncPostBackControl(IncrementButton)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>UpdatePanel in Master Pages</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Master Page<br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Change date
<asp:Button ID="DecrementButton" runat="server" Text="-" OnClick="MasterButton_Click" />
<asp:Button ID="IncrementButton" runat="server" Text="+" OnClick="MasterButton_Click" />
<hr />
<br />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>