Wednesday, December 29, 2010

Microsoft Dynamics CRM 2011

Here is some of the pondering thoughts for exporting and Importing options provided in CRM2011.

Concept of Solution in 2011:
Think of this way, a Solution is a container for the following items:
1. Custom Entities
2. Plugins
3. Customizations
4. Web Resources (May be Images, JavaScript files etc...)

There are two types of solution:
• Managed Solution :(This is locked and does not allow you to change.
Used only at the time of final deployment)
• Unmanaged Solution :(You can think of a pointer, when a change happens
to one of the entity in one of the solution, the other
solution using the same entity will also get affected)

Characteristics of a solution:
1. Publisher: Each solution is associated with a publisher
2. Version Number : very important in installing and uninstalling process
3. Unique Prefix : just like New in CRM 4.0
4. Solutions are unmanaged by default

Differences between Managed and Un Managed Solutions:
Unmanaged Solution
1. Container that holds references to the components.
2. Multiple solutions can reference same components.
3. Solutions are unmanaged by Default.
4. When Solution deleted only the solution ref from the database gets deleted and will not affect the changes done in any of the customizations/Plugins/web Resources.
5. Cannot be uninstalled.

Managed Solution
1. Designed for final distribution
2. Must be exported as managed
3. Cannot be modified and cannot be exported
4. When Solution Deleted, Entities/Components/web Resources and related data gets deleted permanently.
5. Can be uninstalled
6. Changes performed by the solutions are undone

Possible Scenarios of Import and Export process:
Scenario 1: New Deployment: Version 1.0.0.0
1. Export as a managed solution
2. Publish before you export your managed solution
3. Also, possible to export the system settings like Auto numbers, ISV…
4. Create a backup of Customization
5. From the Target Organization Import the Managed Solution.
a. This takes care of registering the plugins by choosing an option while
import.
b. This takes care publishing too, meaning once imported it automatically be
published.
6. Import would not succeed for managed solution from where it has been created.

Scenario 2: Update/Upgrade to a new version of deployment: Version 1.0.0.1 (SAME Solution name and same Publisher)
1. Once done with the changes to any of the components in the solution,
2. Follow the same steps explained in the Version 1.0.0.0, and keep in mind to change the Version Number to Version 1.0.0.1
3. Once you Import your managed solution from the Target organization the process is quite intelligent in identifying your Solution upgrade version by the solution name.

Scenario 3: Patch version of deployment: Version 1.0.0.0 (DIFFERENT Solution
name and same Publisher).
1. Create a solution with a different name
2. Add the components on which the changes are required
3. Associate the Same Publisher
4. Follow a different versioning format like Version 1.0.0.0
5. Follow the same steps explained in Version 1.0.0.0.

Uninstalling Option:
1. Deleting the managed Solution from the target organization would basically uninstall the selected solution.
2. Let’s say if we have followed a few iterations, for example if we have already reached a Version 1.0.0.5 starting from Version 1.0.0.0. in order to rollback to Version 1.0.0.2 we just need to go follow the same Import process and choose the Version 1.0.0.2 while importing. This would basically bring back the changes to the Version 1.0.0.2.

Wednesday, November 17, 2010

Adding Prerequisites in to Visual Studio 2008

o Bootstrapper Manifest Generator Tool URL: http://code.msdn.microsoft.com/bmg/Release/ProjectReleases.aspx?ReleaseId=1567
(is used for generating the manifest file in the Bootstrapper folder of the VS2008 environment)

The above tool will create a folder and add the manifest files to the following location:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages

The folder should have the following files in it:
For example if your adding the SQL Exress 2005 as a prerequisite to the VS 2008,

The tool creates a folder based on the project name provided while creating the
manifest file.

Creating Custom Packages
--------------------------------------------------------------------------------

There are some cases in which you do not have to create a package for your redistributable. Typically, you only have to build packages for shared components or system components, which have to install files to the GAC, perform global registration, or make up a Windows Service.

You should ask the control provider whether you can ship the redistributable file together with the application. If a simple copy operation would be sufficient to redistribute the prerequisite component (for example, if it has no dependencies), you do not have to create a package. Just make sure that the file is included in the setup or that it is set to Copy Local. (The file's Copy property in Properties View should be set to True.)

You should also determine whether you have to use an installer. If so, use a Bootstrapper package.

To create a new component package, you have to supply:

The redistributable component in the form of an EXE or MSI file.

The product manifest, product.xml, which contains any language-neutral metadata for the package. This contains metadata common to all the localized versions of the redistributable component.

The package manifest, package.xml, which contains language-specific metadata; it typically contains localized error messages. A component must have at least one package manifest for each localized version of that component.

How to use the Tool?

Step1:Open the tool and create a project



Step2: Setting up the Manifest project



Step3: Selecting an .exe file


Step4: Final manifest project file


Step5: Build output




Following are the few software download links to configure the Prerequisites in the VS2008

o MDAC Download URL: http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyId=9AD000F2-CAE7-493D-B0F3-AE36C570ADE8&displaylang=en
o SQL Express From FTP: ftp://192.168.1.6/technical/Installables/Microsoft/SQL/SQL 2005 Express SP3

o Crystal Report download URL: http://resources.businessobjects.com/support/additional_downloads/runtime.asp#09 (Follow the attached word document to convert the file to .msi format)

o WSE 3.0 Runtime Download URL: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9e59c3fb-e7bc-4d91-908e-411a8d329f3d&displaylang=en

Some helpful links:

• http://stackoverflow.com/questions/1334436/adding-custom-prerequsites-to-visual-studio-setup-project
• http://msdn.microsoft.com/en-us/library/ms165429.aspx
• http://msdn.microsoft.com/en-us/library/ms165429(v=VS.90).aspx

Thursday, October 7, 2010

One Click Deployment With Visual Studio 2008 and Windows Server

  • Following are the steps that I have followed to publish the one touch deployment on 2008 windows server.
    In VS 2008 right click on the project that we are trying to publish and select properties
    o Select the Application tab from the left navigation in the properties window
    o By default the Manifest option in the Resources group has been defaulted to “Embed manifest with default settings”. Change this option to “Create application without a manifest”
    o From the Signing tab click on “Create Test Certificate” button to sign the assembly with a strong name
    o From the Publish tab provide the Publishing Folder Location information (http:////),where the files need to be deployed.
    o From the “Install Mode and Settings” choose the appropriate online/offline availability option. Also, include the prerequisites if any for the application by clicking on the prerequisites button
    o Provide the publish version and check the automatically increment revision option if you would like to keep the previous version in the deployed location. Basically it maintains the folder by the publish version numbers
    o Click on “Publish” button to start the publish process.

BEFORE WE DO THE ABOVE STEPS:

1)We need to make sure the Windows 2008 server is installed with Front Page Server Extensions. Keep in mind, we need to install the FPSC and Extend the website with FPSC

2)We can't deploy a Click Once application using http to a machine running Windows Server unless the server has the Front Page Extensions installed.

3)Add the following MIME Types for Click Once deployment
o Here are the basic MIME types you need for every Click Once deployment:
 .application –> application/x-ms-application
 .manifest –> application/x-ms-manifest
 .deploy –> application/octet-stream
o If you are targeting .NET 3.5 or .NET 4.0, you need these as well:
 .msp –> application/octet-stream
 .msu –> application/octet-stream
 Click one of these links to see how to set MIME types in IIS 6 or
IIS 7.
 After successful FPSE installation on Windows Server. Follow the
below mentioned steps.
o Extending Web Sites with FPSE
o Using HTML Administration Pages to Extend a Web Site
a. Click Start, point to Programs, point to Administrative Tools, and then
click Microsoft SharePoint Administrator to open the Server
Administration page.
b. In the list of virtual servers, click Extend next to the virtual server
you want to extend.
c. In the Administrator box, type the user name for the administrator of
the virtual server.
d. Click Submit.

4)To overcome this issue “Web Server Does Not Appear to Have Any Authentication
Methods Enabled”
o Right-Click the server name from IIS and click Properties.
o Click the Directory Security tab on the server's properties dialog box.
o Under the Anonymous Access and Authentication Control section, click Edit.
o Choose either Basic Authentication (password sent in Clear Text) or Windows
NT Challenge/Response and click OK twice.
o Stop and restart the Web server.

Friday, November 13, 2009

PDF Fails to open in IE

Actually I was trying to (open/Save As) a pdf file from the IE with SSL (HTTPS) ON,using the report viewr (RDLC). Fortunately it works fine with firefox and not in IE :(. Here is the deal, remove the Cache statement from the below code you are done :).
To know more about the issue please visit this link.

1: Response.Clear();
2: Response.Buffer = true;
3: Response.ContentType = "application/pdf";
4: Response.Cache.SetCacheability(HttpCacheability.NoCache);
5: Response.AddHeader("content-disposition", "attachment;filename=test.pdf");
6: Response.Charset = "";
7: Response.BinaryWrite(pdfContent);
8: Response.End();

Friday, November 6, 2009

.Net Application Development Best Practices

Recommendations for building Highly Available .Net application

Cross cutting related

1.Consider Vertical and Horizontal partitioning of the application logic into layers and tiers, application having independent presentation, business and data layer is essential to build highly scalable and available application
2.Consider Internet Information Server (IIS) 7.0 and above at Web Server and app server tier, Windows Server 2008 as Server Operating System, SQL Server 2005 or higher for Databases
3.Take special care while selecting 3rd party components in the application architecture, usually not appropriately tested components can cause memory, security leaks leading to main application down. e.g. ODP.Net driver version 10.2.0.2.1 causes memory leak issues when used in .Net application. Check and use version which is latest and appropriately tested.
4.Design self healing applications, applications which log data and based on type of error and knows how to recover without administrator intervention.
5.Select logging, tracing and exception management framework which logs correct and useful information. Enterprise Library blocks can be considered for the same. Always provide graceful code exits than aborts.
6.Ensure code review is done for the complete application and standards, best practices are adhered to. No infinite loops, and avoid recursion logic.
7.As far as possible use the namespaces, apis, controls, components available OoB with framework than trying to implement same functionality through user defined programs
8.Thoroughly Test application for security attacks like SQL injection, Denial of service attacks
9.Ensure and plan for soft and hard memory growth with increase in number of users.
10.Ensure software releases, service packs are appropriately tested before rolling out in production.
11. Ensure appropriate latest antivirus software's are installed in the environment
12.Provide appropriate page security using transport security (https), data encryption using encryption algorithms, secure user logins implement certificates using 3rd party security certificates like Verisign.
13.Design system for least access rights, low surface area.
14.Least access right means to run an application, it should need least amount of privileges. Low surface area means application will expose limited software surface area or endpoints which are accessible by other applications, possibly implement this by writing modular windows services.
15.Consider software and hardware firewalls, as far as possible place database server and application server behind firewalls in the order mentioned.
16.Conduct memory profiling, perfmon analysis for appropriate memory and security counters before releasing application into production

Presentation Layer

1.Consider using disconnected scenarios when applicable. Use MS Smart client - Composite Application Block.
2.While designing stateless applications, remember to disable view state of controls, pages.
3.Plan appropriate size aspx pages and avoid too many controls on the page. Split complex functionality into multiple pages, tabs to reduce page size loads.
4.Implement client side Java script validations and report errors at presentation layer itself for data inappropriateness without making server calls
5.Appropriately employ Ajax behavior in the application/pages. Ajax calls leads to increase in network calls.

Business Layer
1.Assign dedicated Application pool for application hosted in IIS
2.Provide Caching in the middle tier and presentation layer.
3. For Distributed Caching, use Velocity framework. For application level caching one can use EL Caching block. Refer this for more info. State server provides reliable cache than InProc.
4.Write deadlock free Database and Dotnet programs, use appropriate threading and monitoring, mutex mechanisms.
5.For long running or Human workflow, consider persisting Workflows. .Net 3.5 has persistence feature which is further improved in .Net 4.0 Windows Workflow.
6.Consider designing stateless WCF services using appropriate configuration parameters for singleton, state full, per session, etc.
7.Use connection, session and thread pools and set respective timeouts
8.As far as possible avoid invoking unmanaged code from .Net, if the need be ensure the unmanaged objects are released from memory
9.Microsoft Dublin, currently in beta can be considered as part of application server for hosting Windows Workflow, WCF, Workflow Services as it provides high availability, scalability, reliability by providing features for persistence, state management, monitoring, etc.
10.Consider .Net Configurations (xml) for driving application settings, as one doesn’t have to restart the application for changes to take place.
11.Consider Clustering, Load balancing for presentation, business logic and Database tier
12.If possible, consider separating stateless logic from state full and plan independent hosting for the respective ones. Consider application pool recycling for stateless sites.
13.Consider setting web garden for multi core CPUs. Number of cores = Maximum Worker processes
14. Consider Caching in the middle tier and presentation layer.
15. For Distributed Caching, use Velocity framework. For application level caching one can use EL Caching block. Refer this for more info.
16.Consider asynchronous communication (fire and forget) patterns for modeling long running transactions, workflows.
17. Appropriately close WCF proxy connections on client, also plan for exception conditions. Recommended practice is mentioned here
18.If not appropriately written, developer written threading logic can cause unexpected application behavior, hence write it only when necessary.
19. Avoid using GC.collect(), as .Net automatically schedules Garbage collection(GC) when memory pressure builds up, no need to force it, as and when GC happens all other operations are suspended.

Persistence Layer

1.Microsoft will stop supporting Oracle driver for .net from 4.0 onwards, if planning to use ODP.net, consider using driver for 11G and above.
2.Physically separate Reporting, data warehousing from real time OLTP data
3.Consider Partitioning (horizontal, vertical) Database.
4. Consider Database Replication options (transactional, merge, snapshot as applicable) for high Database availability.
5. Have appropriate Database archival and backup strategy
By no means this is an exhaustive list; please feel free to add points based on your experience.


Most of these points were collected from Infosys Microsoft blog. Thanks to Sudhanshu Hate for providing these wonderful lists.

MS Chart Control an easy implementation

Basically MS chart control is used to depict the domain data to be repesented in a graphiacl format, which eases the understanding of a user to analyse the domain data. The best simple example that strikes my mind is a sales manager looking at a campaign information of multiple years. Lets see some basics that drives to build a chart control.

Before we dive in to building a chart control lets understand some of the most important chart components that we make use of it in our development.
• Chart Series:
- A series is a related group of data points. Each series is associated with a
chart type
• Chart Area:
- The chart picture consists of one or more chart areas, which are rectangular
areas that are used to draw series, labels, axes, grid lines, tick marks,
and so on. Multiple series can be plotted in one chart area, depending on
the chart types involved.
• Legend:
- A legend for the Chart picture. There can be an unlimited number of legends
in a chart.
• Grid Lines:
- There are major and minor horizontal and vertical grid lines, which usually
occur in conjunction with tick marks
• Tick Marks:
- There are major and minor horizontal and vertical tick marks, which usually
occur in conjunction with grid lines.
• Plot Area:
- The plot area is the inner rectangular area within a chart area that is used
to plot series and grid lines. Labels, tick marks, the axis title, and so
on, are all drawn outside of the plotting area and inside the chart area.
The plot area can be set via the ChartArea.InnerPlotPosition property.
• Axis Label
- Label along an axis
• Axis Title
- The title of an axis
• Chart Picture
- The chart picture, is the entire image surface that is rendered by the Chart
control. It corresponds to the root Chart object.
• Value Label
- A special label that occurs for a data point, slightly offset from where the
point is plotted. It can be the data point's value or custom text.

Below image describes complete picture of all the components of a chart control.







Chart control in aspx page


<asp:CHART ID="aChart" runat="server" BackColor="White" Width="396px" Height="312px" BorderDashStyle="Solid" BackGradientStyle="TopBottom" BorderColor="Silver" BorderSkin-SkinStyle="None">
<legends>
<asp:Legend Docking="Bottom" TableStyle="Wide" IsTextAutoFit="true" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold"></asp:Legend>
</legends>
<series>
<asp:Series MarkerSize="9" BorderWidth="3" Name="CompliantSalesPerStoreDay" LegendText="Series User friendly name" ChartType="Line" BorderColor="180, 26, 59, 105" Color="#99FF33" IsValueShownAsLabel="false" XValueMember="Date[Property/Column[which holds the X axix data]" YValueMembers="Property/Column[which holds the y axix data]" ChartArea="ChartArea1" Legend="Default" YAxisType="Secondary"></asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="White" ShadowColor="Transparent" BackGradientStyle="Center">
<area3dstyle Rotation="25" Perspective="9" LightStyle="Realistic" Inclination="40" IsRightAngleAxes="False" WallWidth="3"/>
<axisy LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</axisy>
<axisx LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</axisx>
</asp:ChartArea>
</chartareas>
<Titles>
<asp:Title Name="Display Execution"></asp:Title>
</Titles>
</asp:CHART>

Some of the important Properties programmatically

//For setting the tool tip
aChart.Series["Seriesname"].ToolTip = "TooltipText";

//Making Visible/Invisible legend information
aChart.Series["Seriesname "].IsVisibleInLegend = false;

// Enable X axis margin
aChart.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;

// Enable 3D, and show data point marker lines
aChart.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;

//Enabling the secondary axis and axix title
aChart.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True;
aChart.ChartAreas[0].AxisY2.Title = "SecondaryAxisTitle";
aChart.ChartAreas[0].AxisY.Title = "YAxixTitle";

//Set Y axis labels format
aChart.ChartAreas["ChartArea1"].AxisY2.LabelStyle.Format = "C2";


//Setting axis labes and intervals
aChart.ChartAreas["ChartArea1"].AxisY2.Minimum = 00.0;
aChart.ChartAreas["ChartArea1"].AxisY2.Maximum = maxY2AxixValue;
aChart.ChartAreas["ChartArea1"].AxisY2.Interval = intervalValue;
aChart.ChartAreas["ChartArea1"].AxisY.Minimum = 0;
aChart.ChartAreas["ChartArea1"].AxisY.Maximum = 1;

//aChart.ChartAreas["ChartArea1"].AxisY.LabelStyle.Format = "0:0%";
aChart.ChartAreas["ChartArea1"].AxisY.LabelStyle.Format = "P2";

// Enable all elements
aChart.ChartAreas["ChartArea1"].AxisX.MinorGrid.Enabled = false;
aChart.ChartAreas["ChartArea1"].AxisX.MinorTickMark.Enabled = true;
aChart.ChartAreas["ChartArea1"].AxisX.MinorGrid.LineColor = Color.Silver;

// Set Title font
aChart.ChartAreas["ChartArea1"].AxisY.TitleFont = new Font("verdana", 8, FontStyle.Bold);
aChart.ChartAreas["ChartArea1"].AxisY2.TitleFont = new Font("verdana", 8, FontStyle.Bold);

// Set Title color
aChart.ChartAreas["ChartArea1"].AxisY.TitleForeColor = Color.Navy;
aChart.ChartAreas["ChartArea1"].AxisY2.TitleForeColor = Color.Navy;

aChart.Series["CompliantCurrent"]["ShowMarkerLines"] = "True";
aChart.Series["CompliantPrior"]["ShowMarkerLines"] = "True";

// Set new legend text font
aChart.Legends["Default"].Font = new Font("Verdana", 8, FontStyle.Regular);

// Set the legend title to Black
aChart.Legends["Default"].ForeColor = Color.Black;

// Set the alignment of the legend title
//aChart.Legends["Default"].Alignment = StringAlignment.Center;

// Disable axis labels auto fitting of text
aChart.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit = false;

// Set axis labels font
aChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font = new Font("verdana", 7, FontStyle.Bold);
aChart.ChartAreas["ChartArea1"].AxisY.LabelStyle.Font = new Font("verdana", 7, FontStyle.Bold);
aChart.ChartAreas["ChartArea1"].AxisY2.LabelStyle.Font = new Font("verdana", 7, FontStyle.Bold);

// Set axis labels angle
aChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = 30;

// Disable offset labels style
aChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.IsStaggered = false;

// Enable X axis labels
aChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Enabled = true;

// Enable AntiAliasing for either Text and Graphics or just Graphics
aChart.AntiAliasing = AntiAliasingStyles.All;

//This basically contolls the look of a chart image
aChart.BorderSkin.SkinStyle = BorderSkinStyle.None;
//Setting Line annotation to chart control this feature
annotation.AnchorDataPoint = point;
annotation.Height = -35;
annotation.ResizeToContent();
annotation.LineWidth = 3;
annotation.ToolTip = "Target Start date:" + dateTime.ToShortDateString();
annotation.LineColor = Color.Green;
annotation.StartCap = LineAnchorCapStyle.None;
annotation.EndCap = LineAnchorCapStyle.None;
aChart.Annotations.Add(annotation);

//Finding Maximum point for the Y axis
//chartData is a list which contains all the series data

decimal? maxValueOfSeries = chartData.Max(c => c.YaxisSeriesName);
var findMax = new List
{
maxValueOfSeries
};
decimal? maxSecondaryAxisValue = findMax.Max();
if (maxSecondaryAxisValue.ToString().Contains("."))
maxSecondaryAxisValue = maxSecondaryAxisValue + 1;

//For the five intervals : Increase it if the interval is more than 5
var secondaryY2AxisIntervalValue = (double)(maxSecondaryAxisValue / 5);

//Note: In any case if the X axis values are set to date and in order to //retrieve the date values, following conversion is required, basically the //the dates are stored in double format.
//Convert Double to DateTime.
DateTime dateTime = DateTime.FromOADate(point.XValue);


Following are the Settings that needs to be entered in the web.config file.
Place them at appropriate level as seen in the enclosed tags.

<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;url=~/website/temp/TempChartImages" />
//Setting Relative path [Create a folder “TempChartImages” in the above defined path]
</appSettings>

<handlers>
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,POST,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
<httpHandlers>
<add path="ChartImg.axd" verb="GET,POST,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<pages><controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>

With this you are done with implementing a chart control.

Download Link: http://www.microsoft.com/downloads/details.aspx?FamilyId=130F7986-BF49-4FE5-9CA8-910AE6EA442C&displaylang=en

Friday, October 23, 2009

Tips and Tricks

Jquery table sorter with Ajax update panel:
jQuery’s plugin Tablesorter to implement client side sorting in ASP.Net Gridview


  • download and include the jQuery and TableSorter js files as follows

  • Add the downloaded Js scripts script tag

  • Include downloaded script in the page [type=“text/javascript” src=“scripts/jquery-latest.js"]

  • Include downloaded script in the page [type=“text/javascript” src=“scripts/jquery.tablesorter.js”]

    Important:
    If you are using update panel, you need to consider using pageLoad function(javascript)


    function pageLoad(sender, args)
    {
    jQuery.fn.fixGridView = function()
    {
    if (jQuery(this).is('table') && this.find('thead').length == 0)
    {
    // No 'thead' section
    // add thead
    //this.prepend("<thead></thead>");
    // remove first row from tbody, add it to thead
    this.find('tbody tr:first').remove().appendTo(this.find('thead'));
    }
    return this;
    };

    $(document).ready(function()
    {
    $("#<%= gvGridID.ClientID %>").fixGridView().tablesorter({
    widthFixed: true,
    widgets: ['zebra'],
    headers: {
    //Set the the column no(Stats with 0) with appropriate flag
    //where you do not want the sorter functionality
    //in the below sampale it is set to 4th column
    4: { sorter: false }
    }
    })
    });
    }
    }


    The above code will set you to run the Jquery sorter method with in update panel, keep in mind the page load metjod of javascript is a must.

    Gridview:
    add this class in your grid view CssClass="tablesorter "


    In the above css class the style contains sorting image. Place the below code in your CSS file.
    table.tablesorter
    {
    border-style:none;
    border-color: #d0d0d0;
    font-size: 11px;
    font-family:arial;
    background-color: #CDCDCD;
    margin:10px 0pt 5px;
    width: 100%;
    text-align: left;
    float: left;
    }
    table.tablesorter thead tr th, table.tablesorter tfoot tr th {
    background-color: #FDF299;
    border-left: 1px solid #d0d0d0;
    border-right: 1px solid #d0d0d0;
    border-bottom: 1px solid #FFF;
    border-top: 1px solid #FFF;
    font-size: 8pt;
    padding: 4px;
    }
    table.tablesorter thead tr .header {
    background-image: url(bg.gif); /*(relative path)*/
    background-repeat: no-repeat;
    background-position: center right;
    cursor: pointer;
    }

    that's all, you are ready to run the grid sorter :).