Wednesday, August 1, 2012

How to embed blogger video audio player all in one plugin for mp3, mp4,mov,.3gp,swf

Lets Rock coding 

<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<script src="http://player.longtailvideo.com/jwplayer.js" type="text/javascript">
</script><br />
<br />
<div id="mediaplayer1">
</div>
<script type="text/javascript">
  jwplayer('mediaplayer1').setup({
    'flashplayer': 'http://player.longtailvideo.com/player.swf',
    
    'width': '480',
    'height': '270',
    'file': 'http://content.longtailvideo.com/videos/8.flv',
    'image': 'http://content.longtailvideo.com/images/8.jpg',
    'plugins': {
       'viral-2': {
           'onpause': 'false',
           'callout': 'none'
       }
    }
  });
</script>

</div>

Sunday, July 8, 2012

How to use substring and len function in sql server 2005 or 2008

I am giving one example from that you will understand How to use Substring and Len Funcation.
Suppose I have one table employee with 1000 of Record. and Having one Column Name is stImage.
This column contain link of Image. stImage contain data like http://www.example.com/images/sqlserversubstring.jpg now I want to change only domain name only replace with http://aspdotnet-example.com/images/sqlserversubstring.jpg for that we will do
update employee set stImage= 'http://aspdotnet-example.com'+
SUBSTRING(stImage,len('http://www.example.com'),len(stImage))
from employee

Tuesday, June 19, 2012

How to Set Identity in Sql Server 2005 or 2008 ?

You have Sql Table Which Having for Example 20 Records. And Identity also 20. Now you want insert new Record with Identity 100 then you pass 99 in below function as Parameter and Table Name and Reseed .
DBCC CHECKIDENT (TableName, reseed, 99)

Tuesday, May 1, 2012

DropDownList value set By FindBy ASP.NET Example

In asp.net there are two ways to FindBy DropdownList. 1.FindByValue and 2.FindByText In FindByValue if more then one List Item text is same then it is working Properly also.
ddlDropDownList.Items.FindByValue(strSearchText).Selected = true;
In FindByText ASP.NET In FindByText if more then one List Item text is same then it is not working Properly also.
ddlDropDownList.Items.FindByText(strSearchText).Selected = true;
There is also other way to DropDownList Select Value through Text but this is Best Way. That's why I choose it.

Friday, March 9, 2012

unable to find the requested .net framework data provider. it may not be installed. sql ce 4.0

unable to find the requested .net framework data provider.
it may not be installed. sql ce 4.0
this error with asp.net mvc music store example.
you have install
in web.config


Monday, March 5, 2012

File Type Filter FileUpload Control

File Upload File Type Filter With ASP.NET
File Upload File Type Filter is not available in asp.net.
There is one way using that we can achieve our goal that is
File Dialogue of Window Desktop Application can filter type but is working only one window7, window xp or
other Microsoft OS only that is not working with Mac,Linux based system for we need to study their file system.  so that is not easy way.

Friday, February 24, 2012

GridView Show Footer And Header No Record in Grid

When No Record in Grid view at that time show Header and Footer.
only we add on Row in Dataset.

GridViewNoRecord.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewNoRecord.aspx.cs" 
Inherits="GridViewNoRecord" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>GridView Show Footer And Header No Record in Grid</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>
<a href="http://aspdotnet-example.blogspot.com/">http://aspdotnet-example.blogspot.com
</a>
</h1>
<h1>GridView Show Footer And Header No Record in Grid</h1>
<asp:GridView ID="gridView" runat="server" AutoGenerateColumns="false" DataKeyNames="MetalId"
EmptyDataText="No Data Found." PageSize="10" CellPadding="4" ForeColor="#333333"
GridLines="None" Style="margin-right: 0px" AllowPaging="True">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="MetalName" HeaderText="GridView Name" ReadOnly="True"
SortExpression="MetalName" />
<asp:BoundField DataField="Status" ItemStyle-HorizontalAlign="Center"
 HeaderText="Is GridView Active?"
ReadOnly="True" SortExpression="Status" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
</form>
</body>
</html>
GridViewNoRecord.aspx.cs 
using System;
using System.Linq;
using System.Web.UI.WebControls;
using System.Data;

public partial class GridViewNoRecord : System.Web.UI.Page

{

    LogicLayer objLogicLayer = new LogicLayer();

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!Page.IsPostBack)
        {

            FillGridView();

        }

    }

    protected void FillGridView()

    {

        if (objLogicLayer.ListMetals().Tables[0].Rows.Count != 0)

        {

            gridView.DataSource = objLogicLayer.ListMetals();

            gridView.DataBind();

        }

        else

        {

            BuildNoRecords(gridView, objLogicLayer.ListMetals());

        }

    }
     public void BuildNoRecords(GridView gridView, DataSet ds)
    {

        try

        {

            ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());

            ds.Tables[0].Rows[0][1] = "No Records Found.";

            gridView.DataSource = ds;

            gridView.DataBind();
}

        catch (Exception ex)

        {

        }

    }

}
GridView Show Footer And Header No Record in Grid

Friday, February 17, 2012

How to send mail using SMTP Mail in asp.net

using System;
using System.Web.Mail;

public class SmtpMailExample
{
public static void Main()
{
string FromSMTP = "from@asp.net";
string ToSMTP = "to@smtp.net";
string SubjectSMTP = "This is a SMTP Test Mail Example Message";
string BodySMTP = "Hi .";

SmtpMail.SmtpServer = "192.168.1.151";
SmtpMail.Send(FromSMTP, ToSMTP, SubjectSMTP, BodySMTP);
}
}

Tuesday, February 14, 2012

call system dll method csharp

call system dll method in csharp application.
in this example we are using User32.dll file.

Monday, February 6, 2012

How to Clear Browser Cache using Javascript ?

This very Common Problem facing web developer. whenever user updating style sheet.
they need to press (Ctrl + F5) for clear browser cache.
 
Now if you are using any JavaScript file  then give name like
for i.e 
JavaScriptFileName.js?Math.random() 
<script type="text/javascript" 
src="http://hostname.net/js/JavaScriptFileName.js?Math.random()">
</script>
 
 
this is solution for clear browser cache.

List View Drag and Drop Control using Jquery

 In this example two things are covered.
1. List View Drag and Drop Control using Jquery 
2. How to read data from XML ?
 dragNdrop.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dragNdrop.aspx.cs" 
Inherits="DragItemInListViewASPNET.dragNdrop" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="JQuery/jquery-ui.css" rel="stylesheet" type="text/css" />
    <script src="JQuery/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="JQuery/jquery-ui.min.js" type="text/javascript"></script>
    <style type="text/css">
        #DragableTable1, #DragableTable2
        {
            list-style-type: none;
            border-right: #669999 2px solid;
            padding-right: 5px;
            border-top: #669999 2px solid;
            padding-left: 5px;
            float: left;
            padding-bottom: 0px;
            margin: 3px;
            border-left: #669999 2px solid;
            width: 160px;
            padding-top: 5px;
            border-bottom: #669999 2px solid;
        }
        #DragableTable1 li, #DragableTable2 li
        {
            border-right: #000 1px solid;
            padding-right: 2px;
            border-top: #000 1px solid;
            padding-left: 2px;
            font-size: 15px;
            margin-bottom: 5px;
            padding-bottom: 2px;
            border-left: #000 1px solid;
            width: 156px;
            cursor: pointer;
            padding-top: 2px;
            border-bottom: #000 1px solid;
            background-color: #eee;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $("#DragableTable1, #DragableTable2").sortable({
                connectWith: ".connectedDragableTable"
            }).disableSelection();
        });

        $(document).ready(function () {
            $("li").dblclick(function () {
                $(this).closest('li').remove();
            });
        });   
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <h1>
        <b>List view Drag and Drop Example</b></h1>
    <br />
    <div>
        <asp:ListView ID="ListView1" runat="server">
            <LayoutTemplate>
                <ul id="DragableTable1" class="connectedDragableTable">
                    <asp:PlaceHolder runat="server" ID="itemPlaceholder">
</asp:PlaceHolder>
                </ul>
            </LayoutTemplate>
            <ItemTemplate>
                <li class="ui-state-default">
                    <%# Eval("Dragvalue1") %></li>
            </ItemTemplate>
        </asp:ListView>
        <asp:ListView ID="ListView2" runat="server">
            <LayoutTemplate>
                <ul id="DragableTable2" class="connectedDragableTable">
                    <asp:PlaceHolder runat="server" ID="itemPlaceholder">
</asp:PlaceHolder>
                </ul>
            </LayoutTemplate>
            <ItemTemplate>
                <li class="ui-state-highlight">
                    <%# Eval("Dragvalue2") %></li>
            </ItemTemplate>
        </asp:ListView>
    </div>
    </form>
</body>
</html>
dragNdrop.aspx.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Data;
namespace DragItemInListViewASPNET
{
    public partial class dragNdrop : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            XmlDocument xmlDocument = new XmlDocument();
            using (DataTable objListView1 = new DataTable())
            {
                objListView1.Columns.Add("Dragvalue1", Type.GetType("System.String"));
 xmlDocument.Load(AppDomain.CurrentDomain.BaseDirectory + "/XmlFile/ListViewData1.xml");
 XmlNodeList xmlNodeList = xmlDocument.SelectNodes("root/data[@open='1']");
                foreach (XmlNode xmlNode in xmlNodeList)
                {
                    DataRow dr = objListView1.NewRow();
                    dr["Dragvalue1"] = xmlNode.InnerText;
                    objListView1.Rows.Add(dr);
                }
                ListView1.DataSource = objListView1;
                ListView1.DataBind();
            }

            XmlDocument xmlDocument2 = new XmlDocument();
            using (DataTable objListView2 = new DataTable())
            {
                objListView2.Columns.Add("Dragvalue2", Type.GetType("System.String"));
xmlDocument2.Load(AppDomain.CurrentDomain.BaseDirectory + "/XmlFile/ListViewData2.xml");
 XmlNodeList xmlNodeList2 = xmlDocument2.SelectNodes("root/data[@open='1']");
                foreach (XmlNode xmlNode in xmlNodeList2)
                {
                    DataRow dr = objListView2.NewRow();
                    dr["Dragvalue2"] = xmlNode.InnerText;
                    objListView2.Rows.Add(dr);
                }
                ListView2.DataSource = objListView2;
                ListView2.DataBind();
            }
        }
    }
}
ListViewData1.xml
<?xml version="1.0" encoding="utf-8" ?>
<root>
  <data open="1">drag and drop element 1</data>
  <data open="1">drag and drop element 2</data>
  <data open="1">drag and drop element 3</data>
  <data open="1">drag and drop element 4</data>
  <data open="1">drag and drop element 5</data>
  <data open="1">drag and drop element 6</data>
  <data open="1">drag and drop element 7</data>
</root>

where clause in asp.net Linq

 This Linq example show you how to use where clause with array

Saturday, February 4, 2012

How to create Chart in asp.net ?

Create Chart control in asp.net
 
 Chart.aspx
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Chart.aspx.cs"
Inherits="Chart" %>

<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting"
TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ASP.NET Chart Control Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1><b>ASP.NET Chart Control Example</b></h1>
<asp:Chart ID="ChartAspnet" runat="server" Height="400px" Width="500px">
<Series>
<asp:Series Name="SeriesASPNET" ChartType="Column" ChartArea="ChartAreaASPnet">
</asp:Series>
<asp:Series Name="SeriesASPNET1" ChartType="Column" ChartArea="ChartAreaASPnet">
</asp:Series>
 
</Series>
 
<ChartAreas>
 
<asp:ChartArea Name="ChartAreaASPnet">
 
</asp:ChartArea>
 
</ChartAreas>
 
</asp:Chart>
 
</div>

 
</form>
</body>
</html>

Monday, January 30, 2012

if condition in gridview source code page

if condition in gridview in source code or .aspx page
this will decrease many operation so performance increase. 
 
<Columns>
  <asp:TemplateField>
    <ItemTemplate>
      <asp:ImageButton ID="ifgridview" runat="server" 
         ImageUrl=<%# ((bool) Eval("condition"))? "yes.png":"no.png" %>
         OnClick="ifgridview_Click" />
    </ItemTemplate>
  </asp:TemplateField>
</columns>

Thursday, January 26, 2012

scroll bar in table

Scrollbar in table is not possible. 
There is one way in that UI is like Scroll bar in table.
 <div style="height: 250px; overflow: scroll;">
<table></table>
</div>
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
And Repeat 1 And Repeat 2 And Repeat 3
Scroll bar Table Cell Content 1 Scroll bar Table Cell Content 2 Scroll bar Table Cell Content 3
More Scroll bar Table Cell Content 1 More Scroll bar Table Cell Content 2 More Scroll bar Table Cell Content 3
Even More Scroll bar Table Cell Content 1 Even More Scroll bar Table Cell Content 2 Even More Scroll bar Table Cell Content 3
End of Scroll bar Table Cell Content 1 End of Scroll bar Table Cell Content 2 End of Scroll bar Table Cell Content 3

Wednesday, January 18, 2012

video audio player all in one plugin for mp3, mp4,mov,.3gp,swf in asp.net,php,jsp








Browser JWPlayer support .mp3, .mp4, .mov, .swf
below example is given
<script type='text/javascript' src='/jwplayer/jwplayer.js'></script>
<div id='mediaplayer'></div>
<script type="text/javascript">
  jwplayer('mediaplayer').setup({
    'flashplayer': 'player.swf',
    'id': 'playerID',
    'width': '480',
    'height': '270',
    'file': 'video.flv',
    'image': 'image.jpg',
    'plugins': {
       'viral-2': {
           'onpause': 'false',
           'callout': 'none'
       }
    }
  });
</script>
  
 Plugin Download

Sunday, October 9, 2011

What is difference between OR (|) and Logical OR (||) ?

1. Logical OR Sign is || and AND Sign is  |.
2. Both work is same but Operation Method is Different 
for example 
if(a==10 || b==10) 
here if a =10 then condition is Satisfied and not going checking values of B. 
Moral One Operation for checking second i.e B values decrasesand in AND & operation 
if(a==10 | b==10)
here if a ==10 then also it is checking B value i.e  it is not necessary.    
    
Logical OR(||) is Best.    

What is difference between AND & and Logical AND &&?

1. Logical AND Sign is && and AND Sign is  &.
2. Both work is same but Operation Method is Different
for example
if(a==10 && b==10)
here if a =10 then only it going for  checking b value
if a !=10 then condition is not satisfied.
Moral One Operation for checking second values decrases
and in AND & operation
if(a==10 & b==10)
here if a !=10 then also it is checking B value it is not necessary.
Logical AND(&&) is Best.    

Wednesday, October 5, 2011

Custom Validation On ServerSide For Validate Number in asp.net

Server Side Custom Validation  For Number. 
it is check regular expression for Number and must be not  null value means 
Required Field Validation.
 
 CustomValidation.aspx 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomValidation.aspx.cs"
    Inherits="CustomValidation" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>CustomValidation ASPdotNet-Example.blogspot.com</title>
</head>
<body>
    <form id="form1" runat="server">
    <center>
    <h1>
        CustomValidation ASPdotNet-Example.blogspot.com</h1>
    <div>
        <table>
            <tr>
                <td>
                &nbsp;
                </td>
                <td>
  <asp:CustomValidator ID="CustomValidatorNumber" runat="server" ForeColor="Red" 
  ControlToValidate="txtValidation" ValidationGroup="Number"
  onservervalidate="CustomValidatorNumber_ServerValidate" 
                        ValidateEmptyText="True"></asp:CustomValidator>
                </td>
            </tr>
            <tr>
                <td>
  <asp:Label ID="lblNumber" runat="server"  Text="Number"></asp:Label>
                </td>
                <td>
 <asp:TextBox ID="txtValidation" ValidationGroup="Number" runat="server">
</asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                &nbsp;
                </td>
                <td>
  <asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="Number"
      onclick="btnSubmit_Click" />
                </td>
            </tr>
            <td>
                &nbsp;
                </td>
                <td>
         <asp:Label ID="lblMsg" runat="server" ForeColor="Green"></asp:Label>
                </td>
        </table>
    </div>
    </center>
    </form>
</body>
</html>
CustomValidation.aspx.cs

Sunday, October 2, 2011

gridview reorder row drag and drop

Drag and Drop GridView Row with jQuery.
Save Display Order in DataBase with WebMethod.
nodrag and nodrop for row that you are not want to drag and drop

gridview reorder row drag and drop




GridViewReOrderDragandDrop.aspx
<%@ Page Language="C#" CodeFile="GridViewReOrderDragandDrop.aspx.cs"
 AutoEventWireup="true" Inherits="GridViewReOrderDragandDrop" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="jquery-1.6.1.js" type="text/javascript"></script>
    <script src="jquery.tablednd_0_5.js" type="text/javascript"></script>
    <style>
        .noselect
        {
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -o-user-select: none;
            user-select: none;
            cursor: move;
        }
        .tDnD_whileDrag
        {
            background-color: Lime;
        }
    </style>
    <title>ASPdotNET-Example.blogspot.com</title>

<script type="text/javascript">
var strorder;
$(document).ready(function() {
$('#GridViewReorder').tableDnD(
{
    onDrop: function(table, row) {
    reorder();
    $.ajax({
             type: "POST",
             url: "GridViewReOrderDragandDrop.aspx/GridViewReorders",
             data: '{"Reorder":"'+strorder+'"}',
             contentType: "application/json; charset=utf-8",
             dataType: "json",
             async: true,
             cache: false,
             success: function (msg) {
             alert("Successfully Save ReOrder");
             }

           })
     }
}
);
});
function  reorder()
{ 
    strorder="";
    var totalid=$('#GridViewReorder tr td input').length;
    for(var i=0;i<totalid;i++)
    {
     strorder=strorder+$('#GridViewReorder tr td input')[i].getAttribute("value")+"|";
    }
}
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <center>
    <h1>GridView Reorder Drag And Drop</h1>
 <div>
 <asp:GridView ID="GridViewReorder" runat="server" HeaderStyle-CssClass="nodrag nodrop"
AutoGenerateColumns="False">
 <Columns>
    <asp:TemplateField ItemStyle-CssClass="noselect" HeaderText="ID">
      <ItemTemplate>
        <asp:Label ID="lblID" runat="server" Text='<%# Bind("id") %>'></asp:Label>
       <asp:HiddenField ID="hdnid" runat="server" Visible="true" Value='<%# Bind("id") %>' />
      </ItemTemplate>
     </asp:TemplateField>
        <asp:TemplateField ItemStyle-CssClass="noselect" HeaderText="Name">
       <ItemTemplate>
         <asp:Label ID="lblName" runat="server" Text='<%# Bind("name") %>'></asp:Label>
         </ItemTemplate>
        </asp:TemplateField>
     <asp:TemplateField HeaderText="Display Order" ItemStyle-CssClass="noselect">
        <ItemTemplate>
          <asp:Label ID="lblOrder" runat="server" Text='<%# Bind("displayorder") %>'>
</asp:Label>
          </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
</div>
    <h1> ASPdotNet-Example.blogspot.com</h1>
    </center>
    </form>
</body>
</html>
 


GridViewReOrderDragandDrop.aspx.cs

using System;
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 System.Data.SqlClient;
using System.Web.Services;
public partial class GridViewReOrderDragandDrop : System.Web.UI.Page 
{
    SqlConnection strCon;
    string sql;
    SqlDataAdapter objAd;
    DataSet objDs;
    protected void Page_Load(object sender, EventArgs e)
    {
        GridViewReorder.DataSource = Con();
        GridViewReorder.DataBind();
    }
    protected DataSet Con()
    {
strCon = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
        objAd = new SqlDataAdapter("ListGrid", strCon);
        objDs = new DataSet();
        objAd.Fill(objDs);
        return objDs;
    }
    [WebMethod]

    public static void GridViewReorders(string Reorder)
    {
        string[] ListID = Reorder.Split('|');
        for (int i = 0; i < ListID.Length; i++)
        {
            if (ListID[i] != "" && ListID[i] !=null)
            {
                updateGridViewReorder(Convert.ToInt16(ListID[i]), i+1);
            }
        }

    }


    public static void updateGridViewReorder(int id, int DisplayOrder)
    {SqlConnection con ;
con= new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
        SqlCommand cmd = new SqlCommand("UpdateOrder");
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Connection = con;
        cmd.Parameters.AddWithValue("@id", id);
        cmd.Parameters.AddWithValue("@DisplayOrder",DisplayOrder);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    
    }
}

 Database Script