Wednesday, May 30, 2012

Wrap the data in Gridview

Sometime the data in Gridview column is large and it makes the scrollbar to appear on the page. Due to which User Interface of page get effected.

Here are two solutions for achieving the required wrapping.

Why two solution are provided?
The reason is that sometime solution 1 doesn't work for all browser. It vary with the way how you are pulling the data in Gridview.

Solution 1:
Putting <ItemStyle> tag and setting the width of column.
Wrapping the data using <ItemStyle> tag
Wrapping the data using <ItemStyle> tag

Solution 2:
Putting <div> tag and styling on bounded column (Works on all browsers)

Wrapping the data using <div> tag and styling
Wrapping the data using <div> tag and styling

Here is the output how data displayed in Gridview is wrapped.

Gridview Wrapping
Gridview wrapping

Keep posting your queries to get optimum solution.

Tuesday, May 29, 2012


Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Data.SQLite' could not be loaded.

System.BadImageFormatException: System.Data.SQLite

Resolution Steps:

1. Goto IIS (inetmgr)
2. Open Application Pools
3. Select the required pool
4. Click on 'Advanced Settings' on right hand side panal
5. Check the 'Enable 32-bit Applications' and set it to true (see below screenshot)
6. Restart the pool and browse your website

IIS Setting
Application Pool Advanced Settings

Wednesday, May 9, 2012

Sitecore Best Practices

Design Prospective:
1. Put components statically in html if it is being used multiple times and not much changes required. Use placeholders only to bind those components which are getting change frequently.
2. Always set presentation details on _standard values.
3. Do appropriate image resizing on server else it will slow down the performance when opening on browse.
4. Create template for providing data to presentation component.
5. Get the Data from DataSource from component Parameters to get variations.

Code Prospective:
1. Test your html/css/javascript code in such a way that Page Editor is enable for edit by non technical staff.
2. Given meaningful names to placeholder so that right component could add under right placeholder.
3. Write code using C# coz this is language generally use by Sitecore Support team.
Use GUID instead of path/name as content can be moved to some other location in content tree.
4. Create separate config file for your component instead of adding directly in web.config.
5. Use Lucene Search in case data is large
6. Do customization(if required) carefully and properly tested as it can impact the performance.

Friday, May 4, 2012

Sitecore customization using pipelines

A pipeline consists of a number of processors arranged in sequence to process a common set of parameters. If I have a series of tasks, which need to be performed to accomplish a task, then a pipeline may be the way to go.
Instead of passing to each processor an arguments object containing these parameters, the pipeline class itself exposes properties representing the parameters.
Sitecore pipelines also allow an object to pass through each step. This object can be manipulated by any of the steps and passed through to the next step until the end is reached and the object can be used by whatever executed the pipeline in the first place.
In configuration file, you will be able to see numbers of pipelines, which is default from sitecore. You can create your own custom code and add pipeline to execute that code.

Pipeline contains parameter ‘type’, which contains information about class and assembly as shown in snapshot.

UI customization using pipelines
Each step in pipeline is called a ‘processor’. Pipeline call the ‘Process’ method from class. Whatever functionality you want to achieve can be written in ‘Process’ method.

For Example:
In this scenario, Pipeline class is inheriting ‘HttpRequestProcessor’ and overriding its Process method to achieve some functionality.

Now code has been written, we have to add pipeline in ‘web.config’ so it could execute. We have added our custom pipeline next to step, where we want to it be executed.

So with just a few lines of code and configuration we can consume benefits of pipeline architecture and perform our custom actions.

Have a great day and enjoy coding !!