views:

760

answers:

1

I have a data-source connected to a stored proc that will return the one record that applies to a specific page, and for another similar situation (populating heading information), I wrapped a repeater around the headings html, and used <%$ Eval() %> binding expressions to get the data into the headings. However, I now have another issue where that does not work.

I have part of my page which uses data from the same data-source as the headings use, and it is a notes section. From the data-source there is a notes field which is a varchar(max) containing HTML.

I used TinyMCE to create a rich editor for the notes, but I want the editor to be populated with the Notes field contents returned by the Data Source. So if TextAreas where able to be in repeaters, I would be set, as I think I can just stuff the html in the text area and TinyMCE will fix it up (I tested with a bold tag around some test text, and it was properly processed).

Is there another way I can use Databinding Eval expressions to populate a text area or something else that TinyMCE can understand, so that the rich text editor will be populated when the page is loaded?

My attempt at this looked like:

<asp:Repeater ID="NotesRepeater" runat="server" DataSourceID="SheetParams">
<textarea style="clear:both; font-size:large" name="notes">
<%# Eval("Notes") %>
</textarea>
</asp:Repeater>

And I have TinyMCE settings of

tinyMCE.init({
    theme: "advanced",
    mode: "textareas",
    width: "95%",
    theme_advanced_buttons1: "bold, italic, underline, strikethrough,|, justifyleft, justifycenter, justifyright, justifyfull,|,formatselect,fontsizeselect",
    theme_advanced_buttons2: "cut, copy, paste,|,bullist, numlist,|,outdent, indent,|,undo,redo",
    theme_advanced_buttons3: ""
});

But of course I get the error Textarea can not be nested in repeater.

+3  A: 

You need to wrap the textarea in an ItemTemplate tag for it to work:

<asp:Repeater ID="NotesRepeater" runat="server" DataSourceID="SheetParams">
   <ItemTemplate>
      <textarea style="clear:both; font-size:large" name="notes">          
         <%# Eval("Notes") %>
      </textarea>
   <ItemTemplate>
</asp:Repeater>
Chris Pebble
Shouldn't that ItemTemplate be around the textarea rather than inside it?
Steven Robbins
Duh, I'm a complete moron.
Tony Peterson
I forgot to put the item template in. I just assumed I wasn't allowed to use it with repeaters at all ;)
Tony Peterson
@Steve, Do'h! Fixed.
Chris Pebble