Feb 12 2009

ASP.NET empty Repeater problem

Classified in: ASP.NETpaomic at 4:17 pm

I was looking for a way to solve the problme of the repeater Control in ASP.NET, which does not offer a functionality like the Empty Data Template of the GridView control or other controls. A solution would be to inherit the Repeater control and create an EmptyTemplate element, as in this post. After some searches I fount this interesting post. The author uses the HeaderTemplate and checks the DataItem count, if it is 0 it shows some text (in the example, it shows a tabel row, but you could easuly do the same with a div or span), otherwise it is hidden. Just what I was looking for! This is the code to use:

<asp:Repeater ID=”repeater” runat=”server”

DataSourceID=”mydatasource” >

<HeaderTemplate>
<span id=”span1″ runat=”server” visible=’<%# ((ICollection)repeater.DataSource).Count == 0 ? true : false %>’>
No data found.
</span>
</HeaderTemplate>

Here repeater is the Id of the Repeater Control.

Tags:

Nov 20 2008

ASP.NET DropDownList and null value (or nullable database field)

Classified in: ASP.NETpaomic at 12:41 pm

If you have an ASP.NET detailsview or similar control, you may already have added extended control, such as radiobuttonlists or dropdowns. If so, you may have experienced and error when you use such controls binded to a database field which is nullable, and has a null value. In this case, the bind fails. To avoid this error, simply add a list item to the collection of the dropdownlist, like this:

<asp:ListItem Selected=”True” Value=”">Nessuna</asp:ListItem>

Add the AppendDataBoundItems property to the dropdownlist:

asp:DropDownList ID=”ddl” runat=”server” DataSourceID=”mydatasource”
DataTextField=”text” DataValueField=”id”
SelectedValue=’<%# Bind(“id”) %>’ AppendDataBoundItems=”true” >

et voila, it works! The trick is using Value=”", which is interpreted as a null value during databinding.

Happy coding!

Tags:

Aug 26 2008

Strange line in Visual Studio 2005

Classified in: Computer jokes, Programmingpaomic at 2:42 pm

Here’s an interesting video of a strange thing: a line on the screen, that is visible only when using Visual Studio!

What could it be?



Jul 11 2008

Debugging ASP.NET applications on Windows Vista

Classified in: ASP.NET, Windowspaomic at 1:43 pm

While debugging an ASP.NET application under Windows Vista, I noticed I could not debug it, because the green arrowhead button next to debug remained green after pressing it, meaning I was not in debug mode. Finally I found out this interesting tutorial. It basically suggests to open Control panel, then program and features, then click on Turn Windows features on and off, and then set the checkbox as the following figure:

Debugging ASP.NET applications on Windows Vista

That’s it!

PS: don’t forget to run Visual Studio 2005 as administrator, clicking on the icon with the right button!

Tags:

Jun 17 2008

Application not initialized correctly (0xc000001d) error and VS2005

Classified in: C/C++, Microsoft, Programmingpaomic at 4:53 pm

While trying to transfer an application created using VS2005 to an embedded PC (VIA C3 M 10000 embedded PC), I run into this very annoying problem. First, I got a slightly different exception, which was due to the msvcr80.dll file missing. So, I used the VS20005 redistributable to deploy the application. But my journey through the DLL hell was only at the beginning, because I got this very strange error. I got this only in the release version of the application, while the debug one worked fine. Using dependency walker, I could check that all the necessary DLLs were there, so I didn’t know what was this. After a couple of days of googling, and an incredible number of rebuild and solution clean, I finally found out that it was due to a DLL (created by me) being compiled in release mode with support for SSE2 istruction set, which was not available in the VIA CPU (it seems that it only supports 3DNow! ones). After removing the SSE/SSE2 optimization, everything worked fine!

Tags:

Next Page »