By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,537 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,537 IT Pros & Developers. It's quick & easy.

Trouble Passing Values from a repeater to a function.

P: n/a
OK I have poked around and have not found an answer to my problem . I
have a repeater that in it's <ItemTemplate> calls a function I want to
pass the current values from the repeater to the function. I have yet
to Figgure out how to get the Evals Data to goto the function as the
current code does not work. Producing an error of :

"System.InvalidOperationException: Databinding methods such as Eval(),
XPath(), and Bind() can only be used in the context of a databound
control."
Any Help Would keep me out of the lonney bin :) Thanks in advance.
This is the repeater
------------------------------------------------------------------------------------------------------------------------------------

<asp:Repeater ID="R2" runat="server" DataSourceID="SqlDataSource2" >

<HeaderTemplate>
<table border=0>
<br />
<br />
<tr>
<td align=left>
</HeaderTemplate>

<ItemTemplate>

<%Answers(Eval("AnswerType"),eval("AnswerID"),Eval ("Answer"))%>

</ItemTemplate>

<FooterTemplate>
</td>
</tr>
</table>
</FooterTemplate>

</asp:Repeater>
--------------------------------------------------------------------------------------------------------------------------------

And this is the function.
--------------------------------------------------------------------------------------------------------------------------------
Protected Sub Answers(ByVal At As String, ByVal AI As String, ByVal A
As String)

output = ""
Select Case AT
Case "radio"
output = output & "<input id=""RB"" type=""radio""
name=""" & AI & """ value=""" & A & """ />" & A & "<br />"
Case "text"
output = output & "<input id=""RB"" type=""text""
name=""" & AI & """ value=""" & A & """ /> <br />"
Case "other"
output = output & "<input id=""RB"" type=""radio""
name=""" & AI & """ value=""" & A & """ />" & A & "<br /> <input
id=""RB"" type=""text"" name=""" & AI & """ value=""" & A & """ /> <br
/>"

Case "list"

End Select
Response.Write(output & vbCrLf)
End Sub

May 18 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.