Monday, February 21, 2011

Issues accessing an HTML table within a Repeater

Very simple scenario: I have a Repeater with a table spanning its Header, Item, and Footer Templates. Because it spans templates, I cannot simply do <table id="Blah" runat="server"> and then access it via FindControl.

Is there any way to overcome this?

EDIT: The goal is to be able to retrieve the HtmlTable then pass it into another method which parses over it, converting it to excel xml.

From stackoverflow
  • In short, no. By turning it into a server control (with runat=server) you can't make it span templates. Why do you need to get to the table element?

    Habaabiai : To pass it elsewhere (just edited this in, see above). I'm currently doing the same with GridViews, passing the entire GridView to an excel export function. Switched to repeaters because they gave us better performance and easier integration with our custom ajax.
  • I was approaching the problem incorrectly. I should have been trying to pass the Repeater, not the HtmlTable. After changing methods, I was able to accomplish my goal and can now export the Repeater contents as XML.

0 comments:

Post a Comment