473,467 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Repeater DataSource. This is driving me crazy.

Hello,

I created a Repeater at runtime with an AccessDataSource.Everything
Works fine!

Now I need to use the same repeater but with a DataSource created in my
VB.Net code.

I created a DataView but the Repeater doesn't show anything!
I don't get any error so I have no idea what is going on.

This is my function which creates the datasource which in this moment
has only one record:

Function DataSource() As ICollection

' Define channels data table
Dim dt As DataTable

' Create channels data table
dt = New DataTable
dt.Columns.Add(New DataColumn("ChannelId", GetType(String)))
dt.Columns.Add(New DataColumn("ChannelName", GetType(String)))

' Add news channel data row
Dim dr As DataRow
dr = dt.NewRow
dr(0) = "News"
dr(1) = "Noticias"
dt.Rows.Add(dr)

' Return RSS channel dataview
DataSource = New DataView(dt)

End Function

Could someone please help me out?

Thanks,
Miguel

Oct 5 '06 #1
2 5080
Here's code that seems to work. Perhaps you could compare it against your
own?

Ken
Microsoft MVP [ASP.NET]

<%@ page language="VB" %>

<%@ import namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Function DataSource() As ICollection

' Define channels data table
Dim dt As DataTable

' Create channels data table
dt = New DataTable
dt.Columns.Add(New DataColumn _
("ChannelId", GetType(String)))
dt.Columns.Add(New DataColumn _
("ChannelName", GetType(String)))

' Add news channel data row
Dim dr As DataRow
dr = dt.NewRow
dr(0) = "News"
dr(1) = "Noticias"
dt.Rows.Add(dr)
dr = dt.NewRow
dr(0) = "Sports"
dr(1) = "Sports2"
dt.Rows.Add(dr)

' Return RSS channel dataview
Return New DataView(dt)

End Function

Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
If Not IsPostBack Then
Repeater1.DataSource = DataSource()
Repeater1.DataBind()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DataSource and Repeater</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:repeater id="Repeater1" runat="server">
<itemtemplate>
<asp:label runat="server" id="lblNews">
<%#Eval("ChannelId")%>:<%#Eval("ChannelName")%></asp:label><br
/>
</itemtemplate>
</asp:repeater>
</div>
</form>
</body>
</html>

"shapper" <md*****@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hello,

I created a Repeater at runtime with an AccessDataSource.Everything
Works fine!

Now I need to use the same repeater but with a DataSource created in my
VB.Net code.

I created a DataView but the Repeater doesn't show anything!
I don't get any error so I have no idea what is going on.

This is my function which creates the datasource which in this moment
has only one record:

Function DataSource() As ICollection

' Define channels data table
Dim dt As DataTable

' Create channels data table
dt = New DataTable
dt.Columns.Add(New DataColumn("ChannelId", GetType(String)))
dt.Columns.Add(New DataColumn("ChannelName", GetType(String)))

' Add news channel data row
Dim dr As DataRow
dr = dt.NewRow
dr(0) = "News"
dr(1) = "Noticias"
dt.Rows.Add(dr)

' Return RSS channel dataview
DataSource = New DataView(dt)

End Function

Could someone please help me out?

Thanks,
Miguel

Oct 5 '06 #2
I just solved it as follows:

' <Asp:Repeater>
Private Sub rRSSChannels_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles rRSSChannels.Init

' Define rRSSChannels properties
With rRSSChannels
.DataSource = rRSSChannels_DataSource()
End With

' Define repeater item template
rRSSChannels.ItemTemplate = New rRSSChannelsTemplate(Me,
ListItemType.Item)

End Sub

Private Sub rRSSChannels_Load(ByVal sender As Object, ByVal e As
EventArgs) Handles rRSSChannels.Load

' Bind repeater to its data source
If Not IsPostBack Then
rRSSChannels.DataBind()
End If

End Sub
Ken Cox [Microsoft MVP] wrote:
Here's code that seems to work. Perhaps you could compare it against your
own?

Ken
Microsoft MVP [ASP.NET]

<%@ page language="VB" %>

<%@ import namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Function DataSource() As ICollection

' Define channels data table
Dim dt As DataTable

' Create channels data table
dt = New DataTable
dt.Columns.Add(New DataColumn _
("ChannelId", GetType(String)))
dt.Columns.Add(New DataColumn _
("ChannelName", GetType(String)))

' Add news channel data row
Dim dr As DataRow
dr = dt.NewRow
dr(0) = "News"
dr(1) = "Noticias"
dt.Rows.Add(dr)
dr = dt.NewRow
dr(0) = "Sports"
dr(1) = "Sports2"
dt.Rows.Add(dr)

' Return RSS channel dataview
Return New DataView(dt)

End Function

Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
If Not IsPostBack Then
Repeater1.DataSource = DataSource()
Repeater1.DataBind()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DataSource and Repeater</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:repeater id="Repeater1" runat="server">
<itemtemplate>
<asp:label runat="server" id="lblNews">
<%#Eval("ChannelId")%>:<%#Eval("ChannelName")%></asp:label><br
/>
</itemtemplate>
</asp:repeater>
</div>
</form>
</body>
</html>

"shapper" <md*****@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hello,

I created a Repeater at runtime with an AccessDataSource.Everything
Works fine!

Now I need to use the same repeater but with a DataSource created in my
VB.Net code.

I created a DataView but the Repeater doesn't show anything!
I don't get any error so I have no idea what is going on.

This is my function which creates the datasource which in this moment
has only one record:

Function DataSource() As ICollection

' Define channels data table
Dim dt As DataTable

' Create channels data table
dt = New DataTable
dt.Columns.Add(New DataColumn("ChannelId", GetType(String)))
dt.Columns.Add(New DataColumn("ChannelName", GetType(String)))

' Add news channel data row
Dim dr As DataRow
dr = dt.NewRow
dr(0) = "News"
dr(1) = "Noticias"
dt.Rows.Add(dr)

' Return RSS channel dataview
DataSource = New DataView(dt)

End Function

Could someone please help me out?

Thanks,
Miguel
Oct 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
2
by: Donald Williamson | last post by:
I have a DataReader that I am binding to a Repeater control. In the DataReader, I have two fields: 'Name1' and 'Name2' 'Name1' will always have a person's name. Name2 periodically has a person's...
4
by: FatboyCanteen | last post by:
I am using a Repeater control(id=Repeater1) to bind a dataset! However, I failed to work for below Command Dim ds as Dataset = CType(Repeater1.datasource, DataSet) I know it can be done by...
0
by: Mike K | last post by:
Hello, I have run into a strange situation. I have a control in which I am trying to sort the datasource of a repeater and bind the arraylist data back to the repeater. Whenever I do this I...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
1
by: fredda054 | last post by:
Hi everybody ! With help from some nice people here I'm getting close to solve my problem with dbnull values in a repeater. I got it pretty much done, I just ned to fix some syntax. I get a...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
1
by: Rory Becker | last post by:
Hi All It's been a while since I tried anything like this and it's just driving me nuts.. I want to have simple templated repeater which contains (Per item) a Label, a textbox and a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.