I have been working on a solution that used the asp:ListView to manipulate data from an access database.
After defining the Layout, Item, EditItem, and Update Templates I was impressed with how much control I had over the display formats and CSS integration that this control allows. The template I was using is a standard html table. The display of the data worked perfectly, but when I attempted to edit a record it replaced everything with blank values. Inserting a new record either gave me an error or inserted a new record with all the fields blank.
I started to troubleshoot by looking at various examples and tutorials on MSDN and the Internet. I could see no difference between what I had coded and the examples. I was using an AccessDataSource and all of the examples were using SqlDataSource, so I redefined the data source to be Sql and still the same behavior, display worked fine but editing did not work.
I am one of those people who prefers to hand code as much as possible to make sure that I am understanding what is happening and how the controls work. But, I had reached my limits, I just could not figure out what I was doing wrong. I broke down and used the wizard for the ListView and let it create the templates and data source. This worked.
So after looking at the templates I discovered one little difference. In my Item templates I had defined the <tr> tags to include the runat=”server” directive. I removed this directive and everything started working like it is supposed to.
Why did this fix it? Well, as near as I can figure when the items are inserted into the template replacing the itemPlaceholder the runat=”server” directive in the item templates overrode / hid / replaced the methods from the itemPlaceholder.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5