Yesterday, I spent the bulk of the day converting a DataList to a ListView. I thought I’d spend a little time relating the process for those of you who might be interested in doing the same.
For the most part, the transition went smoothly.
The first thing I looked at was the structure of the two sets of tags. It was pretty quickly apparent that I was not going to be able to just change the tag name. Not that I expected I could, but it would have been a nice bonus.
What I did notice as I inspected the structure was that both sets have an ItemTemplate tag. So I create a new ListView control pointing at the data I want it to display, and then I moved the itemTemplate tag from the DataList into the new ListView.
Bad move. But, since I’ve already suffered the pain, it won’t be so bad for you. The basic problem stems from the fact that the ListView itemTemplate expects to start and end with a pair of TD tags. In the DataList’s itemTemplate tag, you can put anything you want. So, what you should do is copy the contents of the itemTemplate tag in the DataList into the the ListView’s itemTemplate tag and then put the TD tags around the content you just pasted, and inside the itemTemplate tags.
Not so bad once you figure it out, but if you start this process after a full day of programming, this can be just a bit frustrating.
Like this Article? Subscribe to get every article sent to your email.
- Paging on a Datalist This morning, my email had the following question: “I am having a problem with datalist. Is it possible to do paging on datalist? If yes, what is the solution? I am using VB.NET on […]
- ListView and the DataPager One of the new controls that Visual Studio 2008 brings us is the ListView. Now, the ListView control is really several different controls all rolled into one. There is a lot to see with […]
- Sorting the ListView in ASP.NET Are you confused about how to implement sorting in the new ListView control in ASP.NET 3.5? Join me as I show you in this step by step video showing you exactly how to sort a ListView, […]
- Add/Edit/Delete with ListView Last week we took a short look at the new ListView control in ASP.NET 3.5. Today, we'll take a brief look at Add/Edit/Delete. This is actually pretty simple stuff.
- DotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it […]
About Dave Bush