web 2.0

ASP.NET(vb.net) & AdRotator in DataBinding

ASP.NET(vb.net) & AdRotator in DataBinding - asp:AdRotator : How to use AdRotator control and display AdRotator from data binding or bind the control to a data source.

ShotDev Focus:
- ASP.NET(vb.net) & AdRotator in DataBinding

Example

AdRotatorDataBind.aspx

<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<%@ Page Language="VB" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
AdRotatorDataTable()
AdRotatorDataTableRows()
End Sub

'*** AdRotator & DataTable ***'
Function AdRotatorDataTable()
Dim objConn As OleDbConnection
Dim dtAdapter As OleDbDataAdapter
Dim dt As New DataTable

Dim strConnString As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& _
Server.MapPath("shotdev/mydatabase.mdb")&";"
objConn = New OleDbConnection(strConnString)
objConn.Open()

Dim strSQL As String
strSQL = "SELECT * FROM banner"

dtAdapter = New OleDbDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)

dtAdapter = Nothing
objConn.Close()
objConn = Nothing

'*** AdRotator ***'
With Me.myAdRotator1
.DataSource = dt
.ImageUrlField = "Logo"
.AlternateTextField = "BannerName"
.DataBind()
End With

End Function

'*** AdRotator & TableRows ***'
Sub AdRotatorDataTableRows()
Dim dt As New DataTable
Dim dr As DataRow

'*** Column ***'
dt.Columns.Add("BannerName")
dt.Columns.Add("Logo")

'*** Rows ***'
dr = dt.NewRow
dr("BannerName") = "Banner 1"
dr("Logo") = "images/banner-001.gif"
dt.Rows.Add(dr)

'*** Rows ***'
dr = dt.NewRow
dr("BannerName") = "Banner 2"
dr("Logo") = "images/banner-002.gif"
dt.Rows.Add(dr)

'*** ListBox ***'
With Me.myAdRotator2
.DataSource = dt
.ImageUrlField = "Logo"
.AlternateTextField = "BannerName"
.DataBind()
End With
End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form id="form1" runat="server">
<asp:AdRotator id="myAdRotator1" runat="server"></asp:AdRotator><br /><br />
<asp:AdRotator id="myAdRotator2" runat="server"></asp:AdRotator><br /><br />
</form>
</body>
</html>

Screenshot

ASP.NET(vb.net) & AdRotator in DataBinding
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.