AutoEventWireup and asp:Repeater

So for the last few days I have been scouring through lines and lines of code trying to figure out why the ASP Repeater control <asp:repeater ...> control was not working. 

I checked everything from the record set to the data binding to make sure I had covered all the bases.  Everything checked out but when I loaded the page the data was not displayed.

So in an attempt to troubleshoot the situation I created a new C# web form in VS 2005.  Keeping it simple I added just the one repeater control and data bound it to a single table.  Nothing fancy.  Loaded this page and it worked.

Over the next two days I methodically altered the non-functional page to be almost exactly like the functional page.  I was still having problems.  I even linked in the Master Page, CSS, and other supporting doc's to the functional page to see if it was something in one of them that was causing the problem.  I even altered the Page tag to point at the same CodeFile and still no Luck.

So then I paid a little more attention to this line... 

<%@ Page MasterPageFile="~/StandardLayout.master" Language="C#" AutoEventWireup="false" CodeFile="Default.aspx.cs" Inherits="Default" %>

It is at the top of every page, and I generally don't have reason to mess with it

Then I noticed that in the functional page the AutoEventWireup="true" and this attribute was missing from the non-functional page.

I added this attribute to the non-functional page and reloaded.  IT WORKS!!

So, what is AutoEventWireup and what does it do...

There is an excellent post at

http://odetocode.com/Blogs/scott/archive/2006/02/16/2914.aspx

Scott Allen gives you all the information you need as well as ways to deal with the different behaviors.

Basically my issue boiled down to the fact that the Page_Load event was not firing and so the data binding never occurred.

For performance reasons and not to break other pages I have set the AutoEventWireup to false and used Scott's work around.

Thank you Scott!!!

6. February 2008 06:54 by duners88 | Comments (0) | Permalink
Comments are closed

TextBox

RecentPosts