Friday 27 April 2018

Gridview Horizontal scroll using css on div in asp.net

//////////CSS

div.scrollTable
        {
            overflow: auto;
            white-space: nowrap;
        }
       
        div.scrollTable a
        {
            display: inline-block;
            text-align: center;
            padding: 14px;
            text-decoration: none;
        }



///////////////////// HTML


<div class="scrollTable">
 <asp:GridView runat="server" ID="GV_Reports" AutoGenerateColumns="true" Font-Names="Arial" CssClass="table table-striped table-bordered table-hover table-responsive" Style="width: 100%;"></asp:GridView></div>



///////////Result


Tuesday 24 April 2018

Fixed Gridview header using jquery in asp.net

//////////Use Jquery Plugin

<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script> 

//////////// css
<style type="text/css">

.scrollTblGrid table {
    border-collapse: collapse;
    width: 300px;
    overflow-x: scroll;
    display: block;
}
.scrollTblGrid thead {
    background-color: #EFEFEF;
}
.scrollTblGrid thead, .scrollTblGrid tbody {
    display: block;
}
.scrollTblGrid tbody {
    overflow-y: scroll;
    overflow-x: hidden;
    height: 140px;
}
.scrollTblGrid td, .scrollTblGrid th {
    min-width: 100px;
    height: 25px;
    border: dashed 1px lightblue;
    overflow:hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}
  </style>


////////////////////// html


<div class="scrollTblGrid">
  <table id="tbljaiho">
    <thead>
        <tr><th>Column 1</th><th>Column 2</th><th>Column 3</th><th>Column 4</th><th>Column 5</th></tr>
    </thead>
    <tbody>
        <tr><td>AAAAAAAAAAAAAAAAAAAAAAAAAA</td><td>Row 1</td><td>Row 1</td><td>Row 1</td><td>Row 1</td></tr>
        <tr><td>Row 2</td><td>Row 2</td><td>Row 2</td><td>Row 2</td><td>Row 2</td></tr>
        <tr><td>Row 3</td><td>Row 3</td><td>Row 3</td><td>Row 3</td><td>Row 3</td></tr>
        <tr><td>Row 4</td><td>Row 4</td><td>Row 4</td><td>Row 4</td><td>Row 4</td></tr>
        <tr><td>Row 5</td><td>Row 5</td><td>Row 5</td><td>Row 5</td><td>Row 5</td></tr>
        <tr><td>Row 6</td><td>Row 6</td><td>Row 6</td><td>Row 6</td><td>Row 6</td></tr>
        <tr><td>Row 7</td><td>Row 7</td><td>Row 7</td><td>Row 7</td><td>Row 7</td></tr>
        <tr><td>Row 8</td><td>Row 8</td><td>Row 8</td><td>Row 8</td><td>Row 8</td></tr>
        <tr><td>Row 9</td><td>Row 9</td><td>Row 9</td><td>Row 9</td><td>Row 9</td></tr>
        <tr><td>Row 10</td><td>Row 10</td><td>Row 10</td><td>Row 10</td><td>Row 10</td></tr>
    </tbody>
</table>
</div>




//////////////////////// JS



<script type="text/javascript">
//$(window).load(function(){
//$('table').on('scroll', function () {
//    $("table > *").width($("table").width() + $("table").scrollLeft());
//});
//});
    $(window).load(function () {
        $('#tbljaiho').on('scroll', function () {
$("#tbljaiho > *").width($("#tbljaiho").width() + $("#tbljaiho").scrollLeft());
        });
    });

</script>

/////////////// Result


Filter datatable row with condition using c#

//////////////////////////

//////////////for like conditon


            DataTable checkCluster = Tally_COSTCENTREALLOCATIONS_LIST.Select("Name LIKE 'AP-KMR%'").CopyToDataTable(); //dv4.ToTable();

//////////////for Data  greater than and less than condition

 DataTable checkdate = Tally_VOUCHER.Select("DATE >= '20170401' and DATE <= '20180331'").CopyToDataTable();


//////////////for the date between condition

 DataTable checkdate = Tally_VOUCHER.Select("DATE between '20170401' and  '20180331'").CopyToDataTable();

Find row index inside girdview row click on checkbox using jquery

//////////////////////// HTML

<asp:GridView runat="server" ID="grdclaimdetails">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox runat="server" ID="Personal" onclick="return getRowIndexVal(this);" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>



/////////////////////////js


  <script>
        function getRowIndexVal(Personal) {
            var rc = $('[id$=hdnrc]').val();
            var op1 = $(Personal).attr("id");
            var row = Personal.parentNode.parentNode.parentNode;
            var i = row.rowIndex; //  - 1;
            $('[id$=grdclaimdetails] tr').eq(i + 1).find("td").eq(7).find("input:text[id$=txtcperdiemamt]").val(pval);//value of textbox at cell 7
        }
    </script>

Thursday 5 April 2018

Shift TemplateField in gridview autogeneratecolumns in last column of the row asp.net

//////////////////////HTML

<asp:GridView runat="server" ID="GV_PersonalAttributes" AutoGenerateColumns="true"
    OnRowDataBound="GV_PersonalAttributes_RowCreated">
     <Columns>
      <asp:TemplateField HeaderText="Attributes">
       <ItemTemplate>
         <asp:LinkButton runat="server" ID="lbtn_EditObjective" Text="Edit"></asp:LinkButton>
         </ItemTemplate>
        </asp:TemplateField>
       </Columns>
    </asp:GridView>


/////////////CS


protected void GV_PersonalAttributes_RowCreated(object sender, GridViewRowEventArgs e)
    {
        TableCell cell = e.Row.Cells[0];
        e.Row.Cells.RemoveAt(0);
        e.Row.Cells.Add(cell);
    }

Wednesday 4 April 2018

Data Encryption And Decryption in sql server using ByPassPhrase SQL Funtion

//////////////


declare @Encrypt varbinary(200)
select @Encrypt = EncryptByPassPhrase('key', 'abc' )
select @Encrypt

select convert(varchar(100),DecryptByPassPhrase('key', @Encrypt ))

Data Encryption And Decryption in C# using self define characters

////////////////////


    string mm = "h3dhu12";
    string pp = EnryptString(mm);
    string qq = DecryptString(pp);

        public string EnryptString(string encryptString)
    {
        string EncryptionKey = "qwertyuiopasdfghjklzxcvbnm0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        byte[] clearBytes = System.Text.Encoding.Unicode.GetBytes(encryptString);
        using (Aes encryptor = Aes.Create())
        {
            Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 
            0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 
        });
            encryptor.Key = pdb.GetBytes(32);
            encryptor.IV = pdb.GetBytes(16);
            using (MemoryStream ms = new MemoryStream())
            {
                using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                {
                    cs.Write(clearBytes, 0, clearBytes.Length);
                    cs.Close();
                }
                encryptString = Convert.ToBase64String(ms.ToArray());
            }
        }
        return encryptString;
    }

    public string DecryptString(string cipherText)
    {
        string EncryptionKey = "qwertyuiopasdfghjklzxcvbnm0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        cipherText = cipherText.Replace(" ", "+");
        byte[] cipherBytes = Convert.FromBase64String(cipherText);
        using (Aes encryptor = Aes.Create())
        {
            Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 
            0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 
        });
            encryptor.Key = pdb.GetBytes(32);
            encryptor.IV = pdb.GetBytes(16);
            using (MemoryStream ms = new MemoryStream())
            {
                using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
                {
                    cs.Write(cipherBytes, 0, cipherBytes.Length);
                    cs.Close();
                }
                cipherText = System.Text.Encoding.Unicode.GetString(ms.ToArray());
            }
        }
        return cipherText;
    } 

Simple Data Encryption And Decryption in C# using ASCIIEncoding

/////////////


    string mm = "h3dhu12";
    string pp = EnryptString(mm);
    string qq = DecryptString(pp);
    public string DecryptString(string encrStr)
    {
        byte[] b;
        string decrypted;
        try
        {
            b = Convert.FromBase64String(encrStr);
            decrypted = System.Text.ASCIIEncoding.ASCII.GetString(b);
        }
        catch (FormatException fe)
        {
            decrypted = "";
        }
        return decrypted;
    }

    public string EnryptString(string strEnc)
    {
        byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes(strEnc);
        string encrypted = Convert.ToBase64String(b);
        return encrypted;
    }


Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...