Showing posts with label Ajax. Show all posts
Showing posts with label Ajax. Show all posts

Friday, 14 February 2014

Import And Upload Excel File data into Gridview in Asp.net Usiing C#

Hello Friends!!
In this post I will Explain Import And Upload Excel or we can can Display Excel file data into GridView
In Asp .net Using C#.
I am importing/uploading  an excel file data into a gridview. I have one fileupload control where I need to select an excel file and I have a gridview to show the excel file data and a button where need to click after choosing one excel file so that I can show my excel file data into gridview in asp.net c#.
1  Open Visual Studio
2  Create a new Project(ASP.NET Web Application)
 name it (ImportExcelData)

The whole solution look like in the below image.


To Implement This concept I need to make Excel file that shown in below.


After The Creation Of Excel File ,write the following code in Default.aspx page.
Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ImportExcelData._Default" %>
<!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>
    <script type="text/javascript">
        function Check(sender, args) {
          var fileextension =
           if (fileextension == ".xlsx")
           {
            alert('Select only Xlsx file');
           }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <asp:FileUpload ID="FileUpload1" runat="server" />
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </div>
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="false">
                        <Columns>
                            <asp:BoundField DataField="Name" HeaderStyle-BackColor="Chocolate" HeaderText="Name"
                                ApplyFormatInEditMode="true" ShowHeader="true" NullDisplayText="Null" />
                            <asp:BoundField DataField="Address" HeaderStyle-BackColor="Chocolate" HeaderText="Address"
                                ShowHeader="true" />
                            <asp:BoundField DataField="Salary" HeaderStyle-BackColor="Chocolate" HeaderText="Salary"
                                ShowHeader="true" />
                        </Columns>
                    </asp:GridView>
                </ContentTemplate>
            </asp:UpdatePanel>
            <asp:Button runat="server" ID="BtnUpload" OnClick="BtnUpload_OnClick" Text="Upload" />
        </div>
    </div>
    </form>
</body>
</html>
C# code of Default.aspx.cs
Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data.OleDb;
namespace ImportExcelData
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void BtnUpload_OnClick(object sender, EventArgs e)
        {
            Label1.Text = FileUpload1.PostedFile.FileName;
            if (FileUpload1.HasFile)
            {
                string connectionstring = "";
                string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
                string fileextension = Path.GetExtension(FileUpload1.PostedFile.FileName);
                string filelocation = Server.MapPath("~/file/") + filename;
                FileUpload1.SaveAs(filelocation);
                if (fileextension == ".xlsx")
                {
                    connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filelocation + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=2\"";
                    OleDbConnection conn = new OleDbConnection(connectionstring);
                    OleDbCommand cmd = new OleDbCommand();
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = "select * from [Sheet1$]";
                    cmd.Connection = conn;
                    OleDbDataAdapter oda = new OleDbDataAdapter(cmd);
                    System.Data.DataTable dt = new System.Data.DataTable();
                    oda.Fill(dt);
                    Gridview1.DataSource = dt;
                    Gridview1.DataBind();
                }
            }
            else
            {
                BtnUpload.Attributes.Add("OnClientClick", "javascript:alert('Select Excel file');");
                Gridview1.DataSource = null;
                Gridview1.DataBind();
            }
            FileUpload1.Attributes.Clear();
        }
    }
}

Run the application and see the output as below.




Friday, 7 February 2014

CRUD Operation in ASP.NET Using C# with XML

Hello, I will explain  CRUD (Create, Read Update Delete) operation in XML with the help of ASP.NET DetailsView control. In this post I am explaining to read and write XML file in asp.net using c#.
  1. Open Visual Studio
  2. Create a new Empty Web Site
  3. Add new item>WebForm>name it(xmlinsertion.aspx)

I have created one MasterPage, aspx page with four textbox to enter details and DetailsView control to display data and also delete and update data.

HTML source of page  xmlinsertion.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="xmlinsertion.aspx.cs" Inherits="xmlinsertion" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style type="text/css">
        .style1
        {
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="datagrid">
        <table>
            <thead>
                <tr>
                    <th colspan="2">
                        XML Demo
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="style1">
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        Name:
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="alt">
                    <td class="style1">
                        Address:
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        Email:
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class="alt">
                    <td class="style1">
                        Comment:
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox4" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </td>
                </tr>
                <tr class="alt">
                    <td class="style1" colspan="2">
                                                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Insert" />
                        &nbsp;&nbsp;
                        <asp:Button ID="Button5" runat="server" OnClick="Button5_Click" Text="Cancel" />
                        &nbsp;&nbsp;
                        <asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label>
                        <br />
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" Height="50px"
                            OnItemCommand="DetailsView1_ItemCommand" OnItemDeleting="DetailsView1_ItemDeleting"
                            Width="125px" DataKeyNames="Id" OnModeChanging="DetailsView1_ModeChanging" OnPageIndexChanging="DetailsView1_PageIndexChanging1"
                            AllowPaging="true" DefaultMode="ReadOnly">
                            <Fields>
                                <asp:TemplateField HeaderText="ID">
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Name">
                                    <ItemTemplate>
                                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("name") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Address">
                                    <ItemTemplate>
                                        <asp:Label ID="Label4" runat="server" Text='<%# Eval("address") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Email">
                                    <ItemTemplate>
                                        <asp:Label ID="Label5" runat="server" Text='<%# Eval("email") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Comment">
                                    <ItemTemplate>
                                        <asp:Label ID="Label6" runat="server" Text='<%# Eval("comment") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Edit">
                                    <ItemTemplate>
                                        <asp:Button ID="Button3" runat="server" CommandName="Edit" Text="Edit" />
                                        &nbsp;<asp:Button ID="Button4" runat="server" CommandName="Delete" Text="Delete" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Fields>
                        </asp:DetailsView>
                        <br />
                        <br />
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</asp:Content>

HTML source of page  MasterPage.master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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="StyleSheet.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <h1 class="Title">
        XML DEMO</h1>
    <span class="TagLine">This Is XML DEMO</span>
    <ul class="Menu">
        <li><a href="xmlinsertion.aspx">FillUp</a></li>
    </ul>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

C# code of xmlinsertion.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml;
using System.IO;
public partial class xmlinsertion : System.Web.UI.Page
{
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationTable"].ConnectionString.ToString());
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
             binddetailview();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        DataTable dt = new DataTable("UserInfo");
        if (Button1.Text == "Update")
        {
            int datakeys = Convert.ToInt32(DetailsView1.DataKey["Id"].ToString());
            int lblid = Convert.ToInt32(ViewState["LblId"].ToString());
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(Server.MapPath("samplexml.xml"));
            XmlNodeList nodes = xmldoc.SelectNodes("NewDataSet/UserInfo[Id=" + lblid + "]");
            foreach (XmlNode node in nodes)
            {
                XmlNodeList childnodes = node.ChildNodes;
                foreach (XmlNode childnode in childnodes)
                {
                    switch (childnode.Name)
                    {
                        case "name":
                            childnode.InnerText = TextBox1.Text;
                            break;
                        case "address":
                            childnode.InnerText = TextBox2.Text;
                            break;
                        case "email":
                            childnode.InnerText = TextBox3.Text;
                            break;
                        case "comment":
                            childnode.InnerText = TextBox4.Text;
                            break;
                    }
                }
                childnodes = null;
                break;
            }
            xmldoc.Save(Server.MapPath("samplexml.xml"));
            DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
            DetailsView1.DefaultMode = DetailsViewMode.ReadOnly;
            binddetailview();
            // here Write Remaining Code from XMLGENERATE FILE
        }
        else
        {
            if (File.Exists(Server.MapPath("samplexml.xml")))
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(Server.MapPath("samplexml.xml"));
                XmlTextReader xreader = new XmlTextReader(Server.MapPath("samplexml.xml"));
                ds.ReadXml(xreader);
                DataTable dt1 = new DataTable();
                DataTableReader dtreader = new DataTableReader(ds.Tables["UserInfo"]);
                dt1.Load(dtreader);
                DataRow dtr = dt1.NewRow();
                dtr["name"] = TextBox1.Text;
                dtr["address"] = TextBox2.Text;
                dtr["email"] = TextBox3.Text;
                dtr["comment"] = TextBox4.Text;
                dt1.Rows.Add(dtr);
                xreader.Close();
                dt1.AcceptChanges();
                dt1.WriteXml(Server.MapPath("samplexml.xml"), XmlWriteMode.WriteSchema);
            }
            else
            {
                DataColumn dtc = new DataColumn("Id", typeof(System.Int32));
                DataColumn dtc1 = new DataColumn("name", typeof(System.String));
                DataColumn dtc2 = new DataColumn("address", typeof(System.String));
                DataColumn dtc3 = new DataColumn("email", typeof(System.String));
                DataColumn dtc4 = new DataColumn("comment", typeof(System.String));
                dtc.AutoIncrement = true;
                dtc.AutoIncrementSeed = 1;
                dtc.AutoIncrementStep = 1;
                dtc.ReadOnly = true;
                dt.Columns.Add(dtc);
                dt.Columns.Add(dtc1);
                dt.Columns.Add(dtc2);
                dt.Columns.Add(dtc3);
                dt.Columns.Add(dtc4);
                DataRow dtr = dt.NewRow();
                dtr["name"] = TextBox1.Text;
                dtr["address"] = TextBox2.Text;
                dtr["email"] = TextBox3.Text;
                dtr["comment"] = TextBox4.Text;
                dt.Rows.Add(dtr);
                ds.Tables.Add(dt);
                dt.WriteXml(Server.MapPath("samplexml.xml"), XmlWriteMode.WriteSchema);
            }
        }
        binddetailview();
    }
    protected void binddetailview()
    {
        if (File.Exists(Server.MapPath("samplexml.xml")))
        {
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(Server.MapPath("samplexml.xml"));
            XmlTextReader xreader = new XmlTextReader(Server.MapPath("samplexml.xml"));
            DataTable ds = new DataTable();
            ds.ReadXml(xreader);
            xreader.Close();
            DetailsView1.DataSource = ds;
            DetailsView1.DataBind();
        }
        if (DetailsView1.DefaultMode != DetailsViewMode.Edit)
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox4.Text = "";
            Button1.Text = "Insert";
        }
    }
    protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
    {
        DetailsView1.PageIndex = e.NewPageIndex;
        binddetailview();
    }
    protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            Label lblId = (Label)DetailsView1.FindControl("Label2");
            Label lblname = (Label)DetailsView1.FindControl("Label3");
            Label lbladdress = (Label)DetailsView1.FindControl("Label4");
            Label lblemail = (Label)DetailsView1.FindControl("Label5");
            Label lblcomment = (Label)DetailsView1.FindControl("Label6");
            TextBox1.Text = lblname.Text;
            TextBox2.Text = lbladdress.Text;
            TextBox3.Text = lblemail.Text;
            TextBox4.Text = lblcomment.Text;
            Button1.Text = "Update";
            ViewState["LblId"] = lblId.Text.ToString();
        }
    }
    protected void DetailsView1_ItemDeleting(object sender, DetailsViewDeleteEventArgs e)
    {
        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath("samplexml.xml"));
        ds.Tables["UserInfo"].Rows.RemoveAt(e.RowIndex);
        DataTable dt = (DataTable)ds.Tables["UserInfo"];
        dt.WriteXml(Server.MapPath("samplexml.xml"), XmlWriteMode.WriteSchema);
        binddetailview();
    }
    protected void DetailsView1_PageIndexChanging1(object sender, DetailsViewPageEventArgs e)
    {
        DetailsView1.PageIndex = e.NewPageIndex;
        binddetailview();
    }
    protected void DetailsView1_ModeChanging(object sender, DetailsViewModeEventArgs e)
    {
        if (e.NewMode == DetailsViewMode.Edit)
        {
            DetailsView1.ChangeMode(DetailsViewMode.Edit);
            DetailsView1.DefaultMode = (DetailsViewMode.Edit);
            binddetailview();
        }
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
        DetailsView1.DefaultMode = DetailsViewMode.ReadOnly;
        binddetailview();
    }
}

Run the application and see the output as below.






Thursday, 6 February 2014

How to Bind XML Data to Ajax Reorder List Control

Hellow, I will explain how to bind XML Data to Ajax Reorder List Control in asp.net using c#.

  1. Open Visual Studio
  2. Create a new Empty Web Site
  3.  Add new item>Web Form
  4.  Add new item>XML File >name it(User_Account.xml)

After adding XML file write some data about User Account Deatail.
Below I have write some data into XML file.

User_Account.xml
<?xml version="1.0" encoding="utf-8" ?>
<Party_Account>
  <field>
    <Column Name="Account_Code"></Column>
    <Column Description="Account Code"></Column>
  </field>
  <field>
    <Column Name="Account_Name"></Column>
    <Column Description="Account Name"></Column>
  </field>
  <field>
    <Column Name="Account_Type"></Column>
    <Column Description="Account Type"></Column>
  </field>
  <field>
    <Column Name="Company_Name"></Column>
    <Column Description="Company Name"></Column>
  </field>
  <field>
    <Column Name="Co_Address1"></Column>
    <Column Description="Company Address1"></Column>
  </field>
  <field>
    <Column Name="Co_Address2"></Column>
    <Column Description="Company Address2"></Column>
  </field>
  <field>
    <Column Name="Co_Address3"></Column>
    <Column Description="Company Address3"></Column>
  </field>
  <field>
    <Column Name="Co_City"></Column>
    <Column Description="Company City"></Column>
  </field>
  <field>
    <Column Name="Co_PinCode"></Column>
    <Column Description="Company Pincode"></Column>
  </field>
  <field>
    <Column Name="Co_Phone_No"></Column>
    <Column Description="Company PhoneNo"></Column>
  </field>
  <field>
    <Column Name="Co_MobileNo"></Column>
    <Column Description="Company MobileNo"></Column>
  </field>
  <field>
    <Column Name="Co_FaxNo"></Column>
    <Column Description="Company FaxNo"></Column>
  </field>
  <field>
    <Column Name="Co_CountryID"></Column>
    <Column Description="Company CountryID"></Column>
  </field>
  <field>
    <Column Name="Co_SateID"></Column>
    <Column Description="Company StateID"></Column>
  </field>
  <field>
    <Column Name="Co_EmailID"></Column>
    <Column Description="Company EmailID"></Column>
  </field>
  <field>
    <Column Name="URl"></Column>
    <Column Description="Company URL"></Column>
  </field>
  <field>
    <Column Name="ContactPerson_Name"></Column>
    <Column Description="Contact Person Name"></Column>
  </field>
  <field>
    <Column Name="Address1"></Column>
    <Column Description="Address1"></Column>
  </field>
  <field>
    <Column Name="Address2"></Column>
    <Column Description="Address2"></Column>
  </field>
  <field>
    <Column Name="Address3"></Column>
    <Column Description="Address3"></Column>
  </field>
  <field>
    <Column Name="City"></Column>
    <Column Description="city"></Column>
  </field>
  <field>
    <Column Name="Country_ID"></Column>
    <Column Description="CountryID"></Column>
  </field>
  <field>
    <Column Name="State_ID"></Column>
    <Column Description="StateID"></Column>
  </field>
  <field>
    <Column Name="EmailID"></Column>
    <Column Description="EmailID"></Column>
  </field>
  <field>
    <Column Name="Phone_No"></Column>
    <Column Description="Phoneno"></Column>
  </field>
  <field>
    <Column Name="Mobile_No"></Column>
    <Column Description="MobileNo"></Column>
  </field>
  <field>
    <Column Name="PinCode"></Column>
    <Column Description="Pincode"></Column>
  </field>
  <field>
    <Column Name="CST_No"></Column>
    <Column Description="cstno"></Column>
  </field>
  <field>
    <Column Name="TIN_No"></Column>
    <Column Description="Tin Number"></Column>
  </field>
  <field>
    <Column Name="PAN_No"></Column>
    <Column Description="PAN Card Number"></Column>
  </field>
  <field>
    <Column Name="PF_No"></Column>
    <Column Description="PF Number"></Column>
  </field>
  <field>
    <Column Name="ServiceTax_No"></Column>
    <Column Description="Service tax number"></Column>
  </field>
  <field>
    <Column Name="TAN_No"></Column>
    <Column Description="TAN Number"></Column>
  </field>
  <field>
    <Column Name="VAT_No"></Column>
    <Column Description="VAT Number"></Column>
  </field>
  <field>
    <Column Name="Credit_Period"></Column>
    <Column Description="Credit period"></Column>
  </field>
  <field>
    <Column Name="Credit_Limit"></Column>
    <Column Description="Credit Limit"></Column>
  </field>
  <field>
    <Column Name="Company_ID"></Column>
    <Column Description="Company ID"></Column>
  </field>
  <field>
    <Column Name="ChequePath"></Column>
    <Column Description="ChequePath"></Column>
  </field>
  <field>
    <Column Name="User_Id"></Column>
    <Column Description="User ID"></Column>
  </field>
</Party_Account>

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" 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></title>
    <link href="Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server" style="background-color: #CCCCCC" >
    <div>
        <div>
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
            </asp:ToolkitScriptManager>
        </div>
        <div>
            <asp:ReorderList ID="ReOrList" runat="server" AllowReorder="True" PostBackOnReorder="False"
                ClientIDMode="AutoID">
                <DragHandleTemplate>
                    <div class="ClsDragHandle">
                        <asp:Image ID="Image1" runat="server" ImageUrl="drag1.png" />
                    </div>
                </DragHandleTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbldescription" runat="server" Text='<%#Eval("Description") %>'></asp:Label>
                </ItemTemplate>
            </asp:ReorderList>
        </div>
    </div>
    </form>
</body>
</html>

The code scrap provided below is used to perform to Bind XML Data to Ajax reorder list control.
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
            ReOrList.DataSource = BindData();
            ReOrList.DataBind();
        }
    }
    public System.Data.DataTable BindData()
    {
        System.Data.DataTable dt = new System.Data.DataTable("DTbl_Description");
        try
        {
            System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
            xmldoc.Load(Server.MapPath("User_Account.xml"));
            System.Xml.XmlNodeList xnlist = xmldoc.GetElementsByTagName("Column");
            dt.Columns.Add("Description", typeof(string));
            for (int i = 0; i < xnlist.Count; i++)
            {
                if (xnlist[i].Attributes[0].Name.ToString() == "Description")
                {
                    dt.Rows.Add(xnlist[i].Attributes[0].Value.ToString());
                }
            }
        }
        catch (Exception)
        {
            throw;
        }
        return dt;
    }
}

Run the application and see the output as below.



Below Figure show that after drag item (Address3) in the Reorder list.


Popular Posts

Recent Posts

Sample Text

Stats

Powered by Blogger.

Popular Posts

Popular Posts

Join US on Facebook