Bind Repeater. What am I doing wrong?

S

shapper

Hello,

I am binding a Repeater as follows:

Private Sub rFeedback_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles rFeedback.Load

If Not Page.IsPostBack Then
rFeedback.DataSource = "rFeedback_DataSource"
rFeedback.DataBind()
End If

End Sub ' rFeedback_Load

My datasource is as follows:

Private Function rFeedback_DataSource() As DataTable

Dim dtFeedback As New DataTable
dtFeedback.Columns.Add(New DataColumn("Message", GetType(String)))
Dim drFeedback As DataRow
For Each message As String In Me.Messages
drFeedback = dtFeedback.NewRow
drFeedback("Message") = message
dtFeedback.Rows.Add(drFeedback)
Next message
Return dtFeedback

End Function ' rFeedback_DataSource

Note: Me.Messages is a property of type Generic.List(Of String)

Inside my repeater I have a label which I bind, in an ITemplate class,
as follows:

lMessage.Text = DataBinder.Eval(container.DataItem, "Message")

I get the error, on this last code line:

Exception Details: System.Web.HttpException: DataBinding:
'System.Char' does not contain a property with the name 'Message'.

Any idea why?

I have no idea why is this hapenning.

Thanks,

Miguel
 
T

Teemu Keiski

Umm, you are specifying a string as data source

rFeedback.DataSource = "rFeedback_DataSource"

Remove the double quotes.
 
M

MasterGaurav \(www.edujini-labs.com\)

Umm, you are specifying a string as data source
rFeedback.DataSource = "rFeedback_DataSource"

Remove the double quotes.

Eh! Also put parentheses... calling a method.

rFeedback.DataSource = rFeedback_DataSource()


I'm not a smart guy in VB.Net... but IIRC, parentheses are optional, right?

--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top