Hi
I'm trying to extract information from a dbase into the rotator. This is the code i have so far:
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports Telerik.Web.UI
Imports System.Collections.Generic
Partial Class fullview
Inherits System.Web.UI.Page
Private Structure fileInfo
Public Url As String
Public Image As String
End Structure
Private Property imagesArray() As List(Of fileInfo)
Get
Return DirectCast(ViewState("imagesArray"), List(Of fileInfo))
End Get
Set(ByVal value As List(Of fileInfo))
ViewState("imagesArray") = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rotatorData As New DataTable()
rotatorData.Columns.Add("URL")
rotatorData.Columns.Add("Image")
Dim conn As Data.SqlClient.SqlConnection
Dim cmd As Data.SqlClient.SqlCommand
Dim reader As Data.SqlClient.SqlDataReader
conn = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings.Item(1).ToString)
Dim gal, photo, urli As String
urli = Request.QueryString("galleryName")
'temp = urli.Substring(urli.IndexOf("=") + 1, (urli.IndexOf("&")) - (urli.IndexOf("=") + 1))
gal = urli.Replace("%20", " ")
urli = Request.QueryString("photo")
photo = urli.Replace("%20", " ")
Response.Write(urli & gal & photo)
conn.Open()
cmd = New Data.SqlClient.SqlCommand("select * from Gallery where GalleryName='" & gal & "' and UserID=" & Session("uid"), conn)
imagesArray = New List(Of fileInfo)()
reader = cmd.ExecuteReader
If (reader.HasRows) Then
While (reader.Read())
Dim fInfo As New fileInfo()
fInfo.Url = "<a href=" & Chr(34) & "javascript:ajaxpage('fullview.aspx?galleryname=" & gal & "&photo=" & Trim(reader("PictureURL").ToString) & "','contentarea')" & Chr(34) & ">"
fInfo.Image = "'images/users/" & Session("uid") & "/" & gal & "/Thumbnails/" & Trim(reader("PictureURL").ToString) & "'"
imagesArray.Add(fInfo)
End While
End If
RebindRotator()
End Sub
Private Sub RebindRotator()
Dim rotatorData As New DataTable()
rotatorData.Columns.Add("Url")
rotatorData.Columns.Add("Image")
For Each tempInfo As fileInfo In imagesArray
rotatorData.Rows.Add(New String() {tempInfo.Url, tempInfo.Image})
Next
RadRotator1.DataSource = rotatorData()
RadRotator1.DataBind()
End Sub
End Class
and the aspx:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"
OutputCompression="AutoDetect">
</telerik:RadScriptManager>
<telerik:RadRotator ID="RadRotator1" runat="server">
<ItemTemplate>
<a href="<%# DataBinder.Eval(Container.DataItem, "URL") %>"><img src="<%# DataBinder.Eval(Container.DataItem, "Image") %>"</a>
</ItemTemplate>
</telerik:RadRotator>
<br />
The error i get is:
Server Error in '/profiles' Application.
Compiler Error Message: BC30367: Class 'System.Data.DataTable' cannot be indexed because it has no default property.
Source Error:
I was hoping that since i gleaned this tactic from one of your examples, you might be able to help me with that, since i'm not having much luck on the net.
Thanks in advance.
I'm trying to extract information from a dbase into the rotator. This is the code i have so far:
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports Telerik.Web.UI
Imports System.Collections.Generic
Partial Class fullview
Inherits System.Web.UI.Page
Private Structure fileInfo
Public Url As String
Public Image As String
End Structure
Private Property imagesArray() As List(Of fileInfo)
Get
Return DirectCast(ViewState("imagesArray"), List(Of fileInfo))
End Get
Set(ByVal value As List(Of fileInfo))
ViewState("imagesArray") = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rotatorData As New DataTable()
rotatorData.Columns.Add("URL")
rotatorData.Columns.Add("Image")
Dim conn As Data.SqlClient.SqlConnection
Dim cmd As Data.SqlClient.SqlCommand
Dim reader As Data.SqlClient.SqlDataReader
conn = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings.Item(1).ToString)
Dim gal, photo, urli As String
urli = Request.QueryString("galleryName")
'temp = urli.Substring(urli.IndexOf("=") + 1, (urli.IndexOf("&")) - (urli.IndexOf("=") + 1))
gal = urli.Replace("%20", " ")
urli = Request.QueryString("photo")
photo = urli.Replace("%20", " ")
Response.Write(urli & gal & photo)
conn.Open()
cmd = New Data.SqlClient.SqlCommand("select * from Gallery where GalleryName='" & gal & "' and UserID=" & Session("uid"), conn)
imagesArray = New List(Of fileInfo)()
reader = cmd.ExecuteReader
If (reader.HasRows) Then
While (reader.Read())
Dim fInfo As New fileInfo()
fInfo.Url = "<a href=" & Chr(34) & "javascript:ajaxpage('fullview.aspx?galleryname=" & gal & "&photo=" & Trim(reader("PictureURL").ToString) & "','contentarea')" & Chr(34) & ">"
fInfo.Image = "'images/users/" & Session("uid") & "/" & gal & "/Thumbnails/" & Trim(reader("PictureURL").ToString) & "'"
imagesArray.Add(fInfo)
End While
End If
RebindRotator()
End Sub
Private Sub RebindRotator()
Dim rotatorData As New DataTable()
rotatorData.Columns.Add("Url")
rotatorData.Columns.Add("Image")
For Each tempInfo As fileInfo In imagesArray
rotatorData.Rows.Add(New String() {tempInfo.Url, tempInfo.Image})
Next
RadRotator1.DataSource = rotatorData()
RadRotator1.DataBind()
End Sub
End Class
and the aspx:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"
OutputCompression="AutoDetect">
</telerik:RadScriptManager>
<telerik:RadRotator ID="RadRotator1" runat="server">
<ItemTemplate>
<a href="<%# DataBinder.Eval(Container.DataItem, "URL") %>"><img src="<%# DataBinder.Eval(Container.DataItem, "Image") %>"</a>
</ItemTemplate>
</telerik:RadRotator>
<br />
The error i get is:
Server Error in '/profiles' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.Compiler Error Message: BC30367: Class 'System.Data.DataTable' cannot be indexed because it has no default property.
Source Error:
|
Line 65: Next |
I was hoping that since i gleaned this tactic from one of your examples, you might be able to help me with that, since i'm not having much luck on the net.
Thanks in advance.