473,698 Members | 2,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repeater DataSource. This is driving me crazy.

Hello,

I created a Repeater at runtime with an AccessDataSourc e.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("Cha nnelId", GetType(String) ))
dt.Columns.Add( New DataColumn("Cha nnelName", 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 5097
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="Syst em.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<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 _
("ChannelNam e", 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.EventArg s)
If Not IsPostBack Then
Repeater1.DataS ource = DataSource()
Repeater1.DataB ind()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DataSour ce 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("Channe lId")%>:<%#Eval ("ChannelName") %></asp:label><br
/>
</itemtemplate>
</asp:repeater>
</div>
</form>
</body>
</html>

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

I created a Repeater at runtime with an AccessDataSourc e.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("Cha nnelId", GetType(String) ))
dt.Columns.Add( New DataColumn("Cha nnelName", 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_In it(ByVal sender As Object, ByVal e As
EventArgs) Handles rRSSChannels.In it

' Define rRSSChannels properties
With rRSSChannels
.DataSource = rRSSChannels_Da taSource()
End With

' Define repeater item template
rRSSChannels.It emTemplate = New rRSSChannelsTem plate(Me,
ListItemType.It em)

End Sub

Private Sub rRSSChannels_Lo ad(ByVal sender As Object, ByVal e As
EventArgs) Handles rRSSChannels.Lo ad

' Bind repeater to its data source
If Not IsPostBack Then
rRSSChannels.Da taBind()
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="Syst em.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<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 _
("ChannelNam e", 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.EventArg s)
If Not IsPostBack Then
Repeater1.DataS ource = DataSource()
Repeater1.DataB ind()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DataSour ce 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("Channe lId")%>:<%#Eval ("ChannelName") %></asp:label><br
/>
</itemtemplate>
</asp:repeater>
</div>
</form>
</body>
</html>

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

I created a Repeater at runtime with an AccessDataSourc e.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("Cha nnelId", GetType(String) ))
dt.Columns.Add( New DataColumn("Cha nnelName", 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
2531
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() sorted_feature_vector.sort() #feature_vector.keys()=sorted_feature_vector
2
1654
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 name. So the question is if there is a value in 'Name2', I want to display only that name. Otherwise, display 'Name1' Any help on how to do this? Using VS.NET - vb
4
3134
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 using datagrid !! So, how I can do for this.. Thank You
0
1332
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 get an error stating that there were multiple controls with the same id. The stack trace shows the following: System.Web.UI.Control.BuildProfileTree(String parentId, Boolean
8
2910
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"> <HeaderTemplate><table> </HeaderTemplate> <ItemTemplate>
1
2059
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 parse error on this code because it's not well formed. Can someone please take a look at it and try to find what I'm doing wrong...I've been staring at it for so long now I can't tell up from down. I know it has to be a "'" or a '"' somewhere...
9
4688
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> /asp:Repeater> The DataSource for this Repeater is a CollectionBase of objects and is
8
3022
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 way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
1
4580
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 CustomValidator. Below the Repleater is a single button witha serverside function which changes the text of the button.
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.