Thursday, December 20, 2012

Javascript for character count on keypress

 <script language="javascript" type="text/javascript">


maxL = 1000;
    var bName = navigator.appName;
    function taLimit(taObj) {
        if (taObj.value.length == maxL) return false;
        return true;
    }

    function taCount(taObj, Cnt) {
        objCnt = createObject(Cnt);
        objVal = taObj.value;
        if (objVal.length > maxL) objVal = objVal.substring(0, maxL);
        if (objCnt) {
            if (bName == "Netscape") {
                objCnt.textContent = maxL - objVal.length;
            }
            else { objCnt.innerText = maxL - objVal.length; }
        }
        return true;
    }
    function createObject(objId) {
        if (document.getElementById) return document.getElementById(objId);
        else if (document.layers) return eval("document." + objId);
        else if (document.all) return eval("document.all." + objId);
        else return eval("document." + objId);
    }


 </script>


==================
It is used like as mention below


 <asp:TextBox ID="txtImportaintInfo" runat="server" TextMode="MultiLine"
                                    CssClass="textarea_field2" Width="681px" onpaste="return false" onkeypress="return taLimit(this)" onkeyup="return taCount(this,'myCounter1')"></asp:TextBox>
                                   
<br />     You have <b><span id="myCounter1">1000</span></b>
                                characters remaining for your description...</td>

Tuesday, December 4, 2012

How to convert Sesstion object to array,arrylist in asp.net

converting sesstion to arry

 string[] arrFile = (string[])Session["arrFile"];

converting sesstion to arraylist

 Arraylist arrFile = (Arraylist)Session["arrFile"];

Adding Symbol like as ❏ and ❑ with string in asp.net

There is two sysbole  with shadow:

&#x274f;
&#x2751;

as ❏ and ❑

You can use it  and display like :


❏ Organising necessary form of order to transfer county court possession order to the High Court

❏ Shergroup Legal to attend High Court in London to organisecollection of necessary paperwork

❏ Experienced eviction locksmith on site to change locks and deal with roller shutters etc

❏ Shergroup Security to handle post eviction security services

❏ Shergroup Security to arrange post eviction cleansing

❏ Shergroup Security Risk Assessment Report to highlight measures to prevent further trespass or damage to      property

❏ Any other service not listed here – let us help you complete your eviction process


For this i have use various check box tick value and concatenated and displayed with this function

 private string ConcatCheckBoxText(CheckBox chkBox)
    {
        string str = chkBox.Checked ? "&#x274f; " + chkBox.Text + "<br/><br/>" : "";
        return str;
    }

This bold value in above function is responsible for adding these symbols  ❏ and ❑  in c#

Monday, November 26, 2012

Code for calling SSIS package in asp.net using c#


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.SqlServer.Server;
using Microsoft.SqlServer.Dts;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;
namespace CallPackage
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnexecute_Click(object sender, EventArgs e)
        {
            try
            {
                Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
               Microsoft.SqlServer.Dts.Runtime.Package package = null;
                package =(Microsoft.SqlServer.Dts.Runtime.Package) app.LoadPackage(@"C:\Ajay\Package.dtsx",null,true);
                Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();

                if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
                {
                    foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
                    {

                        Console.WriteLine("Package Execution results: {0}", local_DtsError.Description.ToString());
                        Console.WriteLine();
                    }
                }

            }
            catch (Exception ex)
            {
                string SS = ex.Message;
            }
        }
    }
}

SSIS Package using SQL Server Business Intellegence development Student

Is is used to transfer data in tables of two diffrent database

1.Add Data Flow Task

2.On the Data flow
    A).  Add OLE DB Source:double click and add database source connection string and choose table which need to transfer.
   B).Add OLE DB Destincation :double click and add database destination connection string and choose table in which data need to import.

now just run the application and Both source and destination OLE DB should be green heighlighted.It is a symbol of sucess or if it is showing red the there is error in package.

===============================================

Code for calling package in asp.net using c#



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.SqlServer.Server;
using Microsoft.SqlServer.Dts;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;
namespace CallPackage
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnexecute_Click(object sender, EventArgs e)
        {
            try
            {
                Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
               Microsoft.SqlServer.Dts.Runtime.Package package = null;
                package =(Microsoft.SqlServer.Dts.Runtime.Package) app.LoadPackage(@"C:\Ajay\Package.dtsx",null,true);
                Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();

                if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
                {
                    foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
                    {

                        Console.WriteLine("Package Execution results: {0}", local_DtsError.Description.ToString());
                        Console.WriteLine();
                    }
                }

            }
            catch (Exception ex)
            {
                string SS = ex.Message;
            }
        }
    }
}


    

Friday, November 23, 2012

How to find invalid characters in sql server


CREATE  FUNCTION  FindInvalidValid( @Name NVARCHAR(100) )

RETURNS BIT

BEGIN

    SELECT @Name = RTRIM(ltrim(@Name))

    IF(@name IS null) OR (@Name = '')

      RETURN 1



    DECLARE @len AS INT

    DECLARE @index AS INT

    DECLARE @ascii AS int

    SELECT @len =  LEN(@Name),@index = 1

    WHILE(@index <= @len)

    BEGIN

      SELECT @ascii = ASCII(substring(@Name,@index,1))

      IF ((@ascii BETWEEN 65 AND 90)

         OR (@ascii BETWEEN 97 AND 122)

         OR (@ascii BETWEEN 193 AND 252)

         OR (@ascii = 32)

         OR (@ascii = 45)

         OR (@ascii = 46)

         OR (@ascii BETWEEN 48 AND 57)

         )

      begin

         SELECT @index = @index + 1

         CONTINUE

      end

      ELSE

         RETURN 0

    END

    RETURN 1

END


================================

now use this query for geeting invalid charactor rows


SELECT *

FROM TracedCompanyDetailsttemp

WHERE dbo.IsNameValid(notes1) = 0

OR dbo.IsNameValid(notes1) = 0

Thursday, November 22, 2012

BCP command for Data moving from SQL server to SQL Azure


For making sql  tables to text data files at local drive

bcp databasename.dbo.Client out E:\Shergroup\SqlData\MoveDataFromSQLAzure.txt -c -U sa -S sherbasefive -P 12456

rk5n5pqf6u.database.windows.net


for coping from local dive text data files to sql azure

bcp databasename.dbo.Client in  E:\Shergroup\SqlData\MoveDataFromSQLAzure.txt -c -U myadmin@rk5n5p -S tcp:rk5n5p.database.windows.net -P c0r=jdb

Wednesday, November 21, 2012

highlighting gridview column cell color in asp.net



protected void GDVHistory_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string amtsigh = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Payment_Amt"));
            string minus = amtsigh.Substring(0, 1);
            if (minus == "-")
            {
                e.Row.Cells[2].ForeColor = System.Drawing.Color.Red;
            }

        }
    }

Friday, November 9, 2012

Adding new line after 5 items in list and returning in string using asp.net


1.call method
string PagesNames2 = Convert.ToString( ReturnArrayList(PagesNamesExist));

2.Here is the menthod that adds line break after 5 items

int cnt = 0;
    int warrantIDInt = 0;
    public StringBuilder ReturnArrayList(StringBuilder sb)
    {
        StringBuilder warrantId = new StringBuilder();
        ArrayList warrantIDList = new ArrayList();
        string[] ArryayPageId = sb.ToString().Split(',');
        if (ArryayPageId.Length > 1)
        {
            foreach (string id in ArryayPageId)
            {
                warrantIDList.Add(id);
            }
        }
                         

        if (warrantIDList.Count > 5)
        {
            for (int i = 0; i < warrantIDList.Count; i++)
            {
                string warrantIDStr = warrantIDList[i].ToString();
               
             
                warrantId.Append(warrantIDStr + ",");
                cnt++;
                if (cnt > 5)
                {
                    warrantId.Append("<br/>");
                    cnt = 0;
                }
            }
        }
        else
        {
            for (int i = 0; i < warrantIDList.Count; i++)
            {
                string warrantIDStr = warrantIDList[i].ToString();
                warrantId.Append(warrantIDStr + ",");
            }
        }
        return warrantId;
    }

Thursday, November 1, 2012

How to get selected items value from listbox in c#


if (ListBox1.Items.Count > 0)
        {
            for (int i = 0; i < ListBox1.Items.Count; i++)
            {
                if (ListBox1.Items[i].Selected)
                {
                    string selectedItem = ListBox1.Items[i].Text;
                    //insert command
                }
            }
        }

Friday, October 26, 2012

How to get page name from URL in c#


this.GetType().Name.Split('_')[0]
Or
this.GetType().Name
or
public string GetCurrentPageName() 
{ 
    string sPath = Request.Url.AbsolutePath;
    System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath); 
    string sRet = oInfo.Name; 
    return sRet; 
}

Thursday, October 25, 2012

How to clear Cache on logout in c#


Call this method on page load for clearing cache

 public void ClearApplicationCache()
    {
        List<string> keys = new List<string>();

        IDictionaryEnumerator enumerator = Cache.GetEnumerator();

        while (enumerator.MoveNext())
        {
            keys.Add(enumerator.Key.ToString());
        }

        for (int i = 0; i < keys.Count; i++)
        {
            Cache.Remove(keys[i]);
        }
    }

Monday, October 22, 2012

Caching in ASP.NET using c#

Caching is the ability to store page output and data in memory for the first time it is requested and later we can quickly retrieve them for multiple, repetitious client requests. It is like keeping a copy of something for later use, so we can reduce the load factor on Web servers and database servers by implementing caching on a Web application.

Add dataset to cache....

Cache.Add("dataset", dataset, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 0, 60), System.Web.Caching.CacheItemPriority.Default, null);



Now how to use cache dataset in any page of application

DataSet ds = new DataSet();
ds = (DataSet) Cache["dataset"];

SQl Function for retuning values in tables from sql server


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER FUNCTION [dbo].[GetWarrantNotesDetails] (@WarrantID varchar(22))
   RETURNS @WarrantDetails Table
     (  Remarks     varchar(1000)
      , NoteDate  datetime
      , AddedBy varchar(36)
    )
 AS
   BEGIN
       INSERT INTO @WarrantDetails (Remarks, NoteDate, AddedBy)
        SELECT TOP(1) Remarks, NoteDate,[exec].cname
        FROM warrant_notes iNNER JOIN [exec] ON
       cast(warrant_notes.AddedBy as varbinary) = cast(dbo.[exec].cid as varbinary)    
      WHERE  WarrantID=@WarrantID AND AddedBy<>'Admin' ORDER BY NoteDate DESC
     RETURN
   END

Function for returning single scaler value in sql server


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- =============================================
-- Author: Ajay Kumar
-- Create date: 22-10-2012
-- Description: This function used to get values for allocated users
-- =============================================
CREATE FUNCTION [dbo].[getAllocatedUsers]
(
-- Add the parameters for the function here
@CId varchar(20)
)
RETURNS varchar(20)
AS
BEGIN
-- Declare the return variable here
declare @AllocatedTo varchar(20)

-- Add the T-SQL statements to compute the return value here
SELECT @AllocatedTo=cname from [exec] where cid=@CId

-- Return the result of the function
RETURN @AllocatedTo
END

Friday, October 19, 2012

C# language versions


C# language versions

There are five significant language versions:

C# 1
C# 2, introducing generics, nullable types, anonymous methods, iterator blocks and some other more minor features
C# 3, introducing implicit typing, object and collection initializers, anonymous types, automatic properties, lambda expressions, extension methods, query expressions and some other minor features
C# 4, introducing dynamic typing, optional parameters, named arguments, and generic variance
C# 5, introducing asynchronous functions, caller info attributes, and a tweak to foreach iteration variable capture

Tuesday, October 16, 2012

how to add link in string in asp.net





string Link = "http://www.shnet.net/scollections/ViewReport.aspx?Writ=Writ&WarrantID=" + _warrantid + "";

string Reportlink = "<a href=\"" + Link + "\">RO Report</ID></a>";

Thursday, August 30, 2012

Overlapping Collapsible Panel using AJAX CollapsiblePanelExtender Control

Hi Guys,


For implementing such functionality just add  following things

1.<%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"  TagPrefix="ajax" %>
2.<style type="text/css">
.pnlCSS{
font-weight: bold;
cursor: pointer;
border: solid 1px #c0c0c0;
width:30%;
}
</style>

3. <ajax:ToolkitScriptManager ID="ScriptManager1" runat="server">
            </ajax:ToolkitScriptManager>

4.  <div style="position:absolute; z-index:9999;">

   <asp:Panel ID="PanelClient" runat="server" CssClass="pnlCSS" BorderWidth="0" >
                      <table cellspacing="0" cellpadding="0"  border="0"  >
                        <tr>
                        <td class="tdPurpleMid" colspan="2"><asp:Label ID="LabelClient" runat="server" Text="Client Details"></asp:Label></td>
                     
                         <td   class="tdPurpleMid" style="text-align:right;" colspan="4"  >
                           
                             <asp:ImageButton ID="imgArrows4" runat="server"
                                 style="height: 16px"  />
                             </td>
                       
                        </tr>
                        <tr >
                         <td class="tdPurpleBg" colspan="6"><img alt="" height="4" src="../images/spacer.gif"  /></td>
                          </tr>
                         <tr>
                         <td colspan="6">
                          <asp:Panel ID="CollapsiblPanelClient" runat="server" Height="30" >  
                                                 <table id="Table2" cellspacing="0" cellpadding="0" border="1">
   
                                        <tr>
                                            <td class="tdPurpleLgt" width="122">
                                                <asp:Label ID="lblClientName" runat="server" Text="Client Name"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt" width="280px">
                                                <asp:TextBox ID="txtClientName" runat="server" Width="250px" BorderStyle="None" EnableViewState="true"
                                                    BorderColor="White"  ></asp:TextBox>
                                             
                                            </td>
                                            <td class="tdPurpleLgt" align="left" width="150px">
                                                &nbsp;
                                            </td>
                                            <td class="tdPurpleLgt" align="center" width="10px">
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt" >
                                                <asp:Label ID="lblClientDetails" runat="server"  Text="Client Address"></asp:Label>
                                                </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtAddress1" runat="server" Width="176px" BorderStyle="None"
                                                    BorderColor="White"></asp:TextBox>
                                               
                                            </td>
                                            <td class="tdPurpleLgt" style="width: 3px">
                                                <asp:Label ID="Label10" runat="server" Width="150px" Text="Contact Person Name"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtContactName" runat="server" Width="180px" BorderStyle="None"
                                                    BorderColor="White"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt" width="92">
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtAddress2" runat="server" Width="176px" BorderStyle="None" BorderColor="White"></asp:TextBox>
                                            </td>
                                            <td class="tdPurpleLgt" style="width: 3px">
                                                <asp:Label ID="lblTel1" runat="server" Width="90px" Text="Work Number"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtTel1" runat="server" Width="180px" BorderStyle="None" BorderColor="White"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt" width="92">
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtAddress3" runat="server" Width="176px" BorderStyle="None" BorderColor="White"></asp:TextBox>
                                            </td>
                                            <td class="tdPurpleLgt" style="width: 3px">
                                                <asp:Label ID="lblTel2" runat="server" Width="90px" Text="Mobile Number"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtTel2" runat="server" Width="180px" BorderStyle="None" BorderColor="White"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt" width="92">
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtAddress4" runat="server" Width="176px" BorderStyle="None" BorderColor="White"></asp:TextBox>
                                            </td>
                                            <td class="tdPurpleLgt" style="width: 3px">
                                                <asp:Label ID="lblFax" runat="server" Width="90px" Text="Fax :"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtFax" runat="server" Width="180px" BorderStyle="None" BorderColor="White"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt">
                                                <asp:Label ID="lblClientTown" runat="server" Text="Town"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtClientTown" runat="server" Width="176px" BorderStyle="None" BorderColor="White"></asp:TextBox>
                                            </td>
                                            <td class="tdPurpleLgt" style="width: 3px">
                                                <asp:Label ID="lblDX" runat="server" Width="90px" Text="DX :"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtDX" runat="server" Width="180px" BorderStyle="None" BorderColor="White"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt">
                                                <asp:Label ID="lblClientCounty" runat="server" Text="County"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtClientCounty" runat="server" BorderStyle="None" Width="176px"
                                                    BorderColor="White"></asp:TextBox>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:Label ID="lblEmail" runat="server" Text="Email"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtEmail" runat="server" Width="180px" BorderStyle="None" BorderColor="White"
                                                    MaxLength="100"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt">
                                                <asp:Label ID="lblClientPostalCode" runat="server" Text="Postal Code"></asp:Label>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtClientPostalCode" runat="server" BorderStyle="None" Width="176px"
                                                    BorderColor="White"></asp:TextBox>
                                            </td>
                                            <td class="tdPurpleLgt">Billing Name</td>
                                            <td class="tdPurpleLgt">
                                                <asp:TextBox ID="txtbilling" runat="server" Width="180px" BorderStyle="None" BorderColor="White"
                                                    MaxLength="100"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr >
                                            <td class="tdPurpleLgt" width="92">
                                                A/C Manager</td>
                                            <td class="tdPurpleLgt">
                                                <asp:DropDownList ID="ddlAcountMgr" runat="server" Width="186px">
                                                </asp:DropDownList>
                                            </td>
                                             <td class="tdPurpleLgt">
                                             
                                                Payee Name</td>
                                            <td class="tdPurpleLgt">
                                             
                                                <asp:TextBox ID="txtPayeeName" runat="server" Width="180px" BorderStyle="None" BorderColor="White"
                                                    MaxLength="100"></asp:TextBox>
                                            </td>
                                         
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt" width="92">
                                                Payment Method</td>
                                            <td class="tdPurpleLgt">
                                <asp:DropDownList ID="ddlPyamentMehtod" runat="server" Height="19px"
                                    Width="133px">
                                </asp:DropDownList>
                                            </td>
                                            <td class="tdPurpleLgt">
                                                Credit Card Commission</td>
                                            <td class="tdPurpleLgt">
                                             
                                                                                             
                                                <asp:TextBox ID="txtCCCommission" runat="server" Width="180px"
                                                    BorderStyle="None" BorderColor="White"
                                                    MaxLength="6"></asp:TextBox>
                                                </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt">
                                                VAT</td>
                                            <td class="tdPurpleLgt">
                                             
                                                                                             
                                                <asp:TextBox ID="txtVAT" runat="server" Width="180px"
                                                    BorderStyle="None" BorderColor="White" MaxLength="5"></asp:TextBox>
                                                </td>
                                                 <td class="tdPurpleLgt">
                                                     Remit Collection</td>
                                            <td class="tdPurpleLgt">
                                                <input id="hdnClientid1" runat="server" name="hidden" type="hidden" />
                                             
                                                                                             
                                                <asp:DropDownList ID="ddlRemitCollection" runat="server" Width="186px">
                                                <asp:ListItem Text="Select" Value=""></asp:ListItem>
                                                <asp:ListItem Text="Remit after Deduction" Value="Remit after Deduction"></asp:ListItem>
                                                <asp:ListItem Text="Remit With Invoice" Value="Remit With Invoice"></asp:ListItem>
                                                </asp:DropDownList>
                                             
                                                </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt">
                                                Commission%</td>
                                            <td class="tdPurpleLgt">
                                             
                                                                                             
                                                <asp:TextBox ID="txtCommission" runat="server" Width="180px"
                                                    BorderStyle="None" BorderColor="White"
                                                    MaxLength="5"></asp:TextBox>
                                                   
                                                </td>
                                                 <td class="tdPurpleLgt">
                                                     Payment Terms(days)</td>
                                            <td class="tdPurpleLgt">
                                             
                                                                                             
                                                <asp:TextBox ID="txtPaymentTerms" runat="server" Width="180px"
                                                    BorderStyle="None" BorderColor="White"
                                                    MaxLength="4"></asp:TextBox>
                                                </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt">
                                                Admin Fee</td>
                                            <td class="tdPurpleLgt">
                                             
                                                                                             
                                                <asp:TextBox ID="txtAdminFee" runat="server" Width="180px"
                                                    BorderStyle="None" BorderColor="White"
                                                    MaxLength="6"></asp:TextBox>
                                                </td>
                                                 <td class="tdPurpleLgt">
                                                     Commission Invoices</td>
                                            <td class="tdPurpleLgt">
                                             
                                                                                             
                                                <asp:DropDownList ID="ddlCommissionInvoices" runat="server" Width="186px">
                                                <asp:ListItem Text="Select" Value=""></asp:ListItem>
                                                <asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
                                                <asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
                                                </asp:DropDownList>
                                               
                                                </td>
                                        </tr>
                                        <tr>
                                            <td class="tdPurpleLgt">
                                                Debit Card Commission</td>
                                            <td class="tdPurpleLgt">
                                             
                                                                                             
                                                <asp:TextBox ID="txtDCCommission" runat="server" Width="180px"
                                                    BorderStyle="None" BorderColor="White"
                                                    MaxLength="6"></asp:TextBox>
                                                </td>
                                                 <td class="tdPurpleLgt">
                                                     Admin Invoices</td>
                                            <td class="tdPurpleLgt">
                                             
                                                                                             
                                                <asp:DropDownList ID="ddlAdminInvoices" runat="server" Width="186px">
                                                <asp:ListItem Text="Select" Value=""></asp:ListItem>
                                                <asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
                                                <asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
                                                </asp:DropDownList>
                                               
                                                </td>
                                        </tr>
                                    </table>
                                                </asp:Panel>
                                                </td>
                                                </tr>  
                                                </table>
                                                </asp:Panel>
                       
                       
                       <ajax:CollapsiblePanelExtender ID="CollapsiblePanelExtender2" runat="server"   TargetControlID="CollapsiblPanelClient"
                                Collapsed="True"
                                ExpandControlID="imgArrows4"
                                CollapseControlID="imgArrows4"
                                AutoCollapse="False"
                                AutoExpand="true"
                                ScrollContents="false"
                                TextLabelID="LabelClient"
                                CollapsedText=""
                                ExpandedText=""
                                ImageControlID="imgArrows4"
                                ExpandedImage="../images/left.jpg"
                                CollapsedImage="../images/right.jpg"
                                ExpandDirection="Vertical">
                                    </ajax:CollapsiblePanelExtender>
                                 
    </div>


Tuesday, August 21, 2012

operation is not valid due to the current state of the object. asp.net

If you get such error.....operation is not valid due to the current state of the object. asp.net

Then to resolve this....
Please add  following in webconfig file.



<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="5000" />
 </appSettings>

Friday, July 6, 2012

Getting table structure of all tables from Database in sqlserver 2000/2005

Getting table structure of all tables from database in sqlserver 2005:


SELECT o.name AS TableName,
   c.name AS ColumnName,
   t.name AS DataType,
   c.Max_Length

FROM sysobjects AS o
INNER JOIN syscolumns AS c ON o.object_id = c.object_id
INNER JOIN systypes AS t ON c.user_type_id = t.user_type_id
WHERE type = 'U' ORDER BY TableName


Getting table structure of all tables from  database in  sqlserver 2000:



select table_name,column_name,data_type,character_maximum_length from information_schema.columns
where table_name IN ('AUDIT_WARRANT_PAYMENT_COSTBOOKING',
'AUDIT_WARRANT_PAYMENT_COSTBREAKUP',
'AUDIT_WARRANT_PAYMENTS',
'Brands'')
order by table_name

Wednesday, June 20, 2012

Error handing and sending mail from global.acax file


 void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs
        Exception objErr = new Exception();
        objErr = Server.GetLastError().GetBaseException();
        StringBuilder strMailtext = new StringBuilder();
        strMailtext.Append("Page URL: " + Request.Url.ToString() + "<br>");
        strMailtext.Append("Error Source: " + objErr.Source + "<br>");
        strMailtext.Append("Error Description: " + objErr.Message + "<br>");
        strMailtext.Append("Stack Trace: " + objErr.StackTrace + "<br>");

        MailingUtility objMail = new MailingUtility();
        objMail.SetFromAddress("enquiries@sherforceplus.net");
        objMail.SetFromWhom("Shergroup Security");
        objMail.SetToAddress("a-kumar@sherforce.net");
        objMail.SetCCAddress("");
        objMail.SetMessageBody(strMailtext.ToString());
        objMail.SetSmtpClient("shermail");
        objMail.SendMail("", false);
    }

Tuesday, June 12, 2012

Add new column and its value in Dataset in c#


 dsLetters.Tables[0].Columns.Add(new DataColumn ("ClientRequirement"));
            foreach (DataColumn item in dsLetters.Tables[0].Columns)
            {
                if (item.ToString() == "ClientRequirement")
                {
                    dsLetters.Tables[0].Rows[0]["ClientRequirement"] = clientNeed.ToString();   
                }
            }

Tuesday, May 29, 2012

Hyperlink in gridview item template in c#

1.Add this code to aspx page


<asp:GridView ID="GVClientCaseList" runat="server" AutoGenerateColumns="False"
                                Width="781px" BorderWidth="1px" GridLines="None" CssClass="inputSubmitBtnPrpl_2"
                                PagerSettings-Mode="Numeric" AllowPaging="True" PageSize="20"
                                AllowSorting="True"
                    onpageindexchanging="GVClientCaseList_PageIndexChanging"  >
                                <RowStyle BackColor="#E9E6F0" ForeColor="#4A3C8C" />
                                <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                                <Columns>
   
               
               
                <asp:TemplateField HeaderText="Survey">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:HyperLink ID="hlUrlNA" runat="server" NavigateUrl='<%#FormatUrlSurvey(Eval("WarrantID"))%>'
                                            Text='<%# Eval("WarrantID")%>'>
                                        </asp:HyperLink>
                                    </ItemTemplate>
                                </asp:TemplateField>          

                                 
                                    <asp:BoundField DataField="WarrantID" HeaderText="Fullref">
                                        <HeaderStyle ForeColor="White" Width="15%" />
                                        <ItemStyle HorizontalAlign="left" CssClass="alignGridText"></ItemStyle>
                                    </asp:BoundField>
                                    <asp:BoundField DataField="ClaimantName" HeaderText="Claimant" ItemStyle-HorizontalAlign="center"
                                        ItemStyle-CssClass="alignGridText" ReadOnly="true">
                                        <HeaderStyle ForeColor="White" />
                                        <ItemStyle HorizontalAlign="Center" CssClass="alignGridText"></ItemStyle>
                                    </asp:BoundField>
                                    <asp:BoundField DataField="DefendantName" HeaderText="Defendant" ItemStyle-HorizontalAlign="center"
                                        ItemStyle-CssClass="alignGridText" ReadOnly="true">
                                        <HeaderStyle ForeColor="White" />
                                        <ItemStyle HorizontalAlign="Center" CssClass="alignGridText"></ItemStyle>
                                    </asp:BoundField>
                                   
                                </Columns>
                            </asp:GridView>


2.In Code behind page add this function


  protected string FormatUrlSurvey(object cid)
    {
        return "CaseDetails.aspx?WarrantID=" + cid.ToString();

    }