Thursday, November 29, 2012

Free Heart Surgery for children

Free Heart Surgery for children

Source :

Wednesday, August 22, 2012

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. in Server

There are times when the coexistence of 64 and 32 bit code on the same machine can cause all sorts of seemingly strange issues.
One of them just occurred to me while trying to run the ASPx demos from Developer Express, my main provider of .Net components (the best supplier I’ve ever been able to find).
I was getting the following error:
The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine:
Server Error
It may look otherwise, but this error is generally due to either of two thing:
  • you don’t have Office 2007/2010 Jet drivers installed
  • or you are running a 32 bit application in a default x64 environment.
The first issue is easy to solve, just download the Access 2010 Database Engine from Microsoft (works with Access 2007 databases as well).
For the second one, the fix is also easy enough:
  • For Windows 2008: Navigate to Server Manager > Roles > Web Server (IIS) > Internet Information Services (IIS) Manager, then look under your machine name > Application Pool.
  • For Windows 7: Navigate to Programs > Administrative Tools > Internet Information Services (IIS) Manager, then look under your machine name > Application Pool.
Under there you can call the DefaultAppPool’s advanced settings to change Enable 32-Bits Applications to True:

Advanced Settings
You may have to restart the service for it to take effect but it should work.


Friday, July 27, 2012

How to show aspxpopup control on button click instead of enter key press

1. I have two textboxes  and one button and one aspxpopupcontrol in a aspxwebpage
 2. I attached  Keypress event for two textboxes and i have attached button OnClientClick event from C# code behind to show aspxpopupcontrol.
3. Here problem is when ever i enter some data in any one of the text and press enter it is executing textbox keypress event as well as it showing aspxpopupcontrol. it very annoying to the user.
4. I resolved this issue by using the following devexpress client side method  in textbox keypress event.


  <dx:ASPxTextBox runat="server" ID="txtSearch" ClientInstanceName="txtSearch" NullText="Search by Text"  Style="border-radius: 4px 4px 4px 4px;">
  <ClientSideEvents  KeyPress="function(s,e){ 
                                                                var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);
                                                                if(keypressed ==13)
                                                                        //Your client side functionality goes here
                                                                  }}" />

<dx:ASPxTextBox runat="server" ID="txtTagSearch" ClientInstanceName="txtTagSearch" NullText="Search by Tag"  Style="border-radius: 4px 4px 4px 4px;">
  <ClientSideEvents  KeyPress="function(s,e){ 
                                                                var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);
                                                                if(keypressed ==13)
                                                                        //Your client side functionality goes here
                                                                  }}" />

 <asp:ImageButton ID="btnShowCustomViewBuilder" CausesValidation="true" runat="server" ImageUrl="~/Styles/Images/FilterIcon.png"
                                                         OnClientClick=" popup.Show();  return false"    />

<dx:ASPxPopupControl ID="AspxPopupControl1" runat="server" Modal="True" AutoUpdatePosition="true" HeaderStyle-Font-Bold="true"
    PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" AllowDragging="true" AccessibilityCompliant="false" 
    ShowLoadingPanel="false" HeaderText="Example Popup" ClientInstanceName="popup"  PopupAction="LeftMouseClick" 
        <dx:PopupControlContentControl ID="PopupControlContentControl3" runat="server" SupportsDisabledAttribute="True">

<td> //Your content goes here  </td>


Reference to resolve above issue

Please let me know if you have any doubts on this.

Monday, July 23, 2012

How to Display row value as Column Name in SQL Server

Static Query:

SELECT branch1,branch2,Name,Id  FROM (SELECT top 5   tb.*    from  Users as tb
  ) AS PivotData
PIVOT (COUNT(Location) FOR   Branch  IN (branch1,branch2) ) AS PivotTabllumns

Dynamic Query:

  'SELECT *  FROM (SELECT top 5  tb.* from  ' +  TableName  + ' as tb
) AS PivotData
PIVOT (COUNT(' +  Columns +') FOR  ' +  Columns +' IN ( ' + CColumns + ') ) AS PivotTable'

///Above Columns and CColumns and TableName are the local variables  which are picked from temp table

Instead of "TableName" value you need to pass your table name
Instead of "Columns" On which column(ex: ID,Reference No or any column etc....) you need to perform operation
Instead of "CColumns" you have to pass your own values ex: if your checking for branch count  you need to pass branch name values i.e: branch1, branch2, branch3

If you have any doubts please let me know.

Result :

Thursday, June 28, 2012

Displaying a context menu for Column Headers of an AspxGridView

It is possible we can create context menu on aspxgridview. Find the following example for aspxgridview context menu.


<dx:ASPxGridView ID="grvContexMenuExample" runat="server" AutoGenerateColumns="false"
    KeyFieldName="ID" EnableViewState="true" ClientInstanceName="grdtest" Width="100%"
    Settings-GridLines="None" OnHtmlRowPrepared="grvContexMenuExample_HtmlRowPrepared">
    <ClientSideEvents ContextMenu="function(s,e) {
                                                       if(e.objectType == 'header')
                                                               headerContextMenu.ShowAtPos(e.htmlEvent.clientX, e.htmlEvent.clientY);
                                                         else if(e.objectType == 'row')
                                                             headerContextMenu.ShowAtPos(e.htmlEvent.clientX, e.htmlEvent.clientY);
                                                    }" />

    <%--Your columns goes here--%>

<!--Start New  Context Menu !-->
<dx:ASPxPopupMenu ID="mnContextMenu" runat="server" ClientInstanceName="headerContextMenu"
    EnableAnimation="false" PopupHorizontalAlign="OutsideRight" PopupVerticalAlign="TopSides"
        <dx:MenuItem Text="New Context Menu1">
    <ClientSideEvents ItemClick="ContextMenuItemClick" />
<!--End New   Context Menu !-->


  protected void grvContexMenuExample_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)

            if (e.RowType == GridViewRowType.Data)

                if (e.RowType == GridViewRowType.Header)



Wednesday, June 20, 2012

How to Convert Stream/Xml To DataSet/Datatable

 public static DataSet GetDatasetFromExcel(string FileName)
            bool hasHeaders = true;
            string HDR = hasHeaders ? "Yes" : "No";
            string strConn;
            if (FileName.Substring(FileName.LastIndexOf('.')).ToLower() == ".xlsx")
                strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties=\"Excel 12.0;HDR=" + HDR + ";IMEX=0\"";
                strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties=\"Excel 8.0;HDR=" + HDR + ";IMEX=0\"";

            DataSet output = new DataSet();

            using (OleDbConnection conn = new OleDbConnection(strConn))

                DataTable schemaTable = conn.GetOleDbSchemaTable(
                    OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });

                foreach (DataRow schemaRow in schemaTable.Rows)
                    string sheet = schemaRow["TABLE_NAME"].ToString();

                    if (!sheet.EndsWith("_"))
                            OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + sheet + "]", conn);
                            cmd.CommandType = CommandType.Text;

                            DataTable outputTable = new DataTable(sheet);
                            new OleDbDataAdapter(cmd).Fill(outputTable);
                        catch (Exception ex)
                            throw new Exception(ex.Message + string.Format("Sheet:{0}.File:F{1}", sheet, FileName), ex);
            return output;

Tuesday, June 19, 2012

How to convert object[] to List

List<string> fields = values.Select(i => i.ToString()).ToList();

Solution for the error "Sys.WebForms.PageRequestManagerServerErrorException"


 A number of configuration settings become very relevant when performing uploads. These can be changed by adding sections or values into the Web.Config file. A typical configuration section is given below.
    <add name="Progress" type="WebSupergoo.ABCUpload5.ProgressModule, ABCUpload5, Version=, Culture=neutral, PublicKeyToken=1f89539196ce5fbf"/>

      <add assembly="ABCUpload5, Version=, Culture=neutral, PublicKeyToken=1f89539196ce5fbf" />



httpModules sub-tag

The Progress Module is required for the Pure HTML Progress Bar, for GigUpload and for Corruption Autofix functionality. The Progress Module is a .NET HTTP Module designed to intercept page requests and preprocess them before passing them on to ASP.NET.
To integrate the Progress Module into your ASP.NET application you need to add it using a line in the httpModules subsection of the web.config file. This is shown in the example web.config file above.

compilation sub-tag

To integrate and use ABCUpload objects into your ASP.NET application you need to add a reference to the assembly (stored in the GAC) using a line in the compilation subsection of the web.config file. This is shown in the example web.config file above

httpRuntime maxRequestLength

This attribute is used to limit the size of uploads by rejecting any which exceed a certain limit. The limit refers to the total size of the HTTP upload in KB (approximately equal to the sum of all the files being upload). You should set a sensible limit here to stop malicious visitors using up your bandwidth by uploading excessively large files.
If the size of an upload is too great the server will refuse to accept it. Because the server is refusing the request the uploading browser will report that the submission page is not available. This is a client side error message rather than a server side error message and it means that you cannot normally provide a sensible error message to users if they submit files which are too large.
However using ABCUpload you can report back a sensible error message via a progress window. If you believe that visitors may attempt to perform uploads greater than the maximum you should use the progress bar and the note on the progress window will inform your visitor why their upload has been rejected.
In the example web.config file above the maxRequestLength is set to 1 GB.

httpRuntime executionTimeout

The execution time-out refers to the number of seconds an ASP.NET page is given before the operation is assumed to have failed and the page terminated. If you are uploading a large file the code that is receiving the transfer may time out before the file has been completely uploaded.
In the example web.config file above the executionTimeout is set to one hour.

sessionState timeout

The session time-out refers to the number of minutes before the user session is aborted. If a large file is being uploaded it is desirable to maintain the session state. The session time-out should always be longer than the amount of time you expect uploads to take. Note that this value is only relevant if you have session state enabled.
In the example web.config file above the sessionState is set to one hour.

processModel responseDeadlockInterval

The responseDeadlockInterval is specified in the machine.config file and defaults to three minutes. It specifies the time interval after which the process will be restarted if no responses have been made and requests are still queued.
Under ASP.NET requests that take longer than the deadlock interval can cause problems under some very specific circumstances. Sometimes a client may make multiple page requests which ASP.NET may queue one after the other. If the first request in the queue takes longer than the deadlock interval then ASP.NET will mistakenly assume the whole process is deadlocked and restart it. These types of situation are very unusual and are more commonly encountered in test environments than real world ones.
For this situation to arise a client must make multiple uploads simultaneously. At least two uploads must take longer than the timeout. The client must make other page requests at the same time which IIS must decide to queue (whether it decides to queue them or not depends on whether IIS thinks they form part of the same session). These queued requests must not time out or be dismissed on the client side. Neither the client nor any other visitors must make other aspx page requests during this time.

How to Find First and Last Day of Current Month

SELECT @mydate = GETDATE()
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101) ,
'Last Day of Previous Month'
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101) AS Date_Value,
'First Day of Current Month' AS Date_Type
SELECT CONVERT(VARCHAR(25),@mydate,101) AS Date_Value, 'Today' AS Date_Type
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),101) ,
'Last Day of Current Month'
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))-1),DATEADD(mm,1,@mydate)),101) ,
'First Day of Next Month'


 ----YesterdaySELECT DATEADD(d,-1,GETDATE()) 'Yesterday' 
----First Day of Current WeekSELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) 'First Day of Current Week'
 ----Last Day of Current WeekSELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) 'Last Day of Current Week' 
----First Day of Last WeekSELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0) 'First Day of Last Week' 
----Last Day of Last WeekSELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6) 'Last Day of Last Week' 
----First Day of Current MonthSELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) 'First Day of Current Month' 
----Last Day of Current MonthSELECT DATEADD(ms,- 3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0))) 'Last Day of Current Month'
 ----First Day of Last MonthSELECT DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)) 'First Day of Last Month'
 ----Last Day of Last MonthSELECT DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))) 'Last Day of Last Month'
 ----First Day of Current YearSELECT DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0) 'First Day of Current Year' 
----Last Day of Current YearSELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE())+1,0))) 'Last Day of Current Year' 
----First Day of Last YearSELECT DATEADD(yy,-1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)) 'First Day of Last Year' 
----Last Day of Last YearSELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0))) 'Last Day of Last Year'

How to display alert message from javascript inside the ASPXCallbackPanel

protected void OnCallback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) 
         ASPxCallbackPanel callbackPanel = (ASPxCallbackPanel)source;       
          callbackPanel.Controls.Add(new LiteralControl("My New Content"));        
         WebControl script = new WebControl(HtmlTextWriterTag.Script);        
      script.Attributes["id"] = "dxss_123456";        
    script.Attributes["type"] = "text/javascript";        
     script.Controls.Add(new LiteralControl("var str = 'test'; alert(str);"));    

City, State and Country usingcascading dropdownlist(through Webservice)

ASP.Net Page:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:DropDownList ID="ddlCountry" CssClass="ddlist" Width="202" runat="server">
<asp:CascadingDropDown ID="CountryCascading" runat="server" Category="Country"  TargetControlID="ddlCountry"
PromptText="Select Country" ServiceMethod="BindCountrydropdown" LoadingText="Loading Countries..."
<asp:DropDownList ID="ddlState" CssClass="ddlist" Width="202" runat="server">
<asp:CascadingDropDown ID="StateCascading" runat="server" Category="State" TargetControlID="ddlState"
ParentControlID="ddlCountry" LoadingText="Loading States..." PromptText="Select State"
ServiceMethod="BindStatedropdown" ServicePath="~/Assets/DropdownWebService.asmx">
<asp:DropDownList ID="ddlCity" CssClass="ddlist" Width="202" runat="server">
<asp:CascadingDropDown ID="RegionCascading" runat="server" Category="Region" TargetControlID="ddlCity"
ParentControlID="ddlState" LoadingText="Loading Cities..." PromptText="Select City"
ServiceMethod="BindRegiondropdown" ServicePath="~/Assets/DropdownWebService.asmx">

.CS File

  CountryCascading.SelectedValue = objCompanyDT.Rows[0]["CountryID"].ToString();

if (ddlCountry.SelectedItem.Text != "Select Country" && ddlCountry.SelectedItem.Text != "")
  objCompany.Country = ddlCountry.SelectedItem.Value;

In Web Service File:

using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.Specialized;
using AjaxControlToolkit;
using System.Configuration;
using System.Data;
using IUSCRMLib.DataManagers;
namespace IUSCRM.Assets
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class DropdownWebService : System.Web.Services.WebService
public CascadingDropDownNameValue[] BindCountrydropdown(string knownCategoryValues, string category)
  SqlConnection concountry = IUSCRMLib.SqlHelper.GetDBConnetion();
  SqlCommand cmdcountry = new SqlCommand("select * from Countries where IsActive=1",  concountry);
  SqlDataAdapter dacountry = new SqlDataAdapter(cmdcountry);
  DataSet dscountry = new DataSet();
  List<CascadingDropDownNameValue> countrydetails = new List<CascadingDropDownNameValue>();
  foreach (DataRow dtrow in dscountry.Tables[0].Rows)
    string CountryID = dtrow["CountryId"].ToString();
    string CountryName = dtrow["Country"].ToString();
    countrydetails.Add(new CascadingDropDownNameValue(CountryName, CountryID));
  return countrydetails.ToArray();
public CascadingDropDownNameValue[] BindStatedropdown(string knownCategoryValues, string category)
  int CountryID;
  StringDictionary countrydetails =  AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
  CountryID = Convert.ToInt32(countrydetails["Country"]);
  SqlConnection constate = IUSCRMLib.SqlHelper.GetDBConnetion();
  SqlCommand cmdstate = new SqlCommand("select * from State where CountryID=@CountryID and  State <> (select Country from Countries where CountryId=@CountryID) and IsActive=1", constate);
  cmdstate.Parameters.AddWithValue("@CountryID", CountryID);
  SqlDataAdapter dastate = new SqlDataAdapter(cmdstate);
  DataSet dsstate = new DataSet();
  List<CascadingDropDownNameValue> statedetails = new List<CascadingDropDownNameValue>();
  foreach (DataRow dtstaterow in dsstate.Tables[0].Rows)
     string stateID = dtstaterow["StateID"].ToString();
     string statename = dtstaterow["State"].ToString();
     statedetails.Add(new CascadingDropDownNameValue(statename, stateID));
  return statedetails.ToArray();
public CascadingDropDownNameValue[] BindRegiondropdown(string knownCategoryValues, string category)
  int stateID;
  StringDictionary statedetails = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
  stateID = Convert.ToInt32(statedetails["State"]);
  SqlConnection conregion = IUSCRMLib.SqlHelper.GetDBConnetion();
  SqlCommand cmdregion = new SqlCommand("Select * from Cities where StateID=@StateID and City <> (select state from state where StateID=@StateID) and IsActive=1 ", conregion);
  cmdregion.Parameters.AddWithValue("@StateID", stateID);
  SqlDataAdapter daregion = new SqlDataAdapter(cmdregion);
  DataSet dsregion = new DataSet();
  List<CascadingDropDownNameValue> regiondetails = new List<CascadingDropDownNameValue>();
  foreach (DataRow dtregionrow in dsregion.Tables[0].Rows)
     string regionID = dtregionrow["CityId"].ToString();
     string regionname = dtregionrow["City"].ToString();
     regiondetails.Add(new CascadingDropDownNameValue(regionname, regionID));
  return regiondetails.ToArray();