Friday 26 November 2010

BLACK FRIDAY/CYBER MONDAY DEAL:

Note  I don’t normally post adds for products but this is really easy to create icons I’m always creating favicons for my sites and it make the task real easy.

sale

All Axialis products are available at 50 percent Off. Starting Black Friday, this offer ends Nov 30. This is for 5 days, and 5 days only. Half price but full service! You get the same Axialis advantages: professionally-designed products, LIFETIME LICENCE! (never pay for future updates), access to thousands of ready-to-use image object packs, and more...

So don't miss this opportunity! ACT NOW and get 50 percent off your total order!

IconWorkshop 6.53 Released:

IconWorkshop

This minor release includes various bug fixes and enhancements:

  • Compatible with Visual Studio 2010: The installer detects and add the IconWorkshop add-in in Visual Studio 2010.
  • Ability to create icons for iPhone 4: This new version includes new image presets to create those icons.
  • New Object Packs: Two new object packs are provided to create iPhone icons (Applications and Tab Bar Icons).
  • Various other enhancements and bug fixes.

Registered users can freely upgrade to this latest version using the built-in update feature.

Sunday 21 November 2010

Five Cool Filters for Dynamic Data 4

Starting with the Range Autocomplete, Range & MultiForeignKey Filters from the old Dynamic Data Preview 4 Refresh, I have also added five of my filters:

  1. DateRange
  2. StartsWith
  3. EndsWith
  4. Contains
  5. Where

I won’t go into much detail here as Oleg Sych has done this great series on DD4 filters, that pretty much explains it all for you.

I am using the Ajax Control Toolkit for the date picker in the DateRange filter but other than that it’s not much different form the Range filter from the Dynamic Data Preview 4 Refresh sample.

!Important: One thing I would like to point out is that both Entity Framework and Linq to SQL have a small but important issue. This issue is the the “Contains” Expression used in the above filter of the same name is actually expressed as the “Like ‘%{0}%’” and so you DO NOT get full text search using “Contains”.

“Contains” when it was introduced in SQL Server 7 was given a big build up and to be omitted in EF and L2S is a big let down.

Some examples:

Other Filters

Figure 1 – DateRange, StartsWith, EndsWith, Contains, Where and AutoComplete filters

Range and Multi Select Filters

Figure 2 – Range and Multi Select Filters

I just thought that these filters would be useful for your tool boxes.

!Important: I can’t take credit for all the Expression helpers most come from the above mentioned Preview 4 that is no longer on the ASP.Net Codeplex site.
Download

Note I’ve included my five filters and the three filters from the Preview.

As always happy coding.

Sunday 14 November 2010

Making the Text in the DynamicData List Pages GridView Wrap.

Why won’t the text in my Dynamic Data List page GridView wrap? This is answered here and in this post on the ASP.NET Dynamic Data Forum here Re: DynamicField within GridView truncating data where Yuipcheng asks;

“I commented out the code to truncate the FieldValueString, but the rendered text doesn't wrap since the td tag has (style="white-space: nowrap;")”

I answered here but I thought I would document it here also.

Before After
Before After

So you may be asking Dynamic Data 1 didn’t do this, so why does Dynamic Data 4 do it?

The answer it has to do with the validation “*”  showing up next to the field in Edit mode and appears to have just gotten into the GridView as by default we don't do inline editing.

The solution from David Fowler is to create an class and inherit from System.Web.DynamicData.DefaultAutoFieldGenerator and then override the CreateField method, so here it is:

/// <summary>
/// Add the option to the Default Auto Field Generator 
/// to not add the (Style="white-space: nowrap;") to each field.
/// </summary>
public class AdvancedAutoFieldGenerator : DefaultAutoFieldGenerator
{
    private Boolean _noWrap;

    /// <summary>
    /// Initializes a new instance of the 
    /// <see cref="AdvancedAutoFieldGenerator"/> class.
    /// </summary>
    /// <param name="table">The table.</param>
    /// <param name="noWrap">if set to <c>true</c> 
    /// the (Style="white-space: nowrap;") is added 
    /// to each field.</param>
    public AdvancedAutoFieldGenerator(MetaTable table, Boolean noWrap)
        : base(table)
    {
        _noWrap = noWrap;
    }

    protected override DynamicField CreateField(
        MetaColumn column, 
        ContainerType containerType, 
        DataBoundControlMode mode)
    {
        DynamicField field = base.CreateField(column, containerType, mode)

        // override the wrap behavior
        // with the noWrap parameter
        field.ItemStyle.Wrap = !_noWrap;
        return field;
    }
}

Listing 1 – Advanced Field Generator

and we apply it in the Page_Load event of the List page (or you own custom page)

// apply custom auto field generator
GridView1.ColumnsGenerator = new AdvancedAutoFieldGenerator(table, false);

This will then remove the unwanted style,

Note: If you still want this on some pages I have not hard coded it, so you can change it in code where you want to.