Contact Form

Name

Email *

Message *

Jquery Data table using Listview with Paging and search (client side) in asp.net


 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>  
 <!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="jqury/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />  
 </head>  
 <body>  
 <form id="form1" action="UserRegistration.html" runat="server">  
   <asp:ListView ID="lstfinance" runat="server" >  
   <LayoutTemplate>  
       <table id="example" class="display" cellspacing="0" width="100%">  
       <thead>  
       <tr>  
         <th>Region</th>  
         <th>Zone</th>  
         <th>Territory</th>  
         <th>E-Code</th>  
         <th>Employee</th>  
         <th>Category</th>  
         <th>Product</th>  
         <th>PackSize</th>  
         <th>SaleQty</th>  
         <th>Rate</th>  
         <th>IncentiveValue</th>   
       </tr>  
       </thead>  
       <tfoot>  
       <tr>  
         <th>Region</th>  
         <th>Zone</th>  
         <th>Territory</th>  
         <th>E-Code</th>  
         <th>Employee</th>  
         <th>Category</th>  
         <th>Product</th>  
         <th>PackSize</th>  
         <th>SaleQty</th>  
         <th>Rate</th>  
         <th>IncentiveValue</th>   
       </tr>  
       </tfoot>  
        <tbody>  
             <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>  
           </tbody>  
       </table>  
     </LayoutTemplate>  
  <ItemTemplate>  
       <tr>  
         <td><%# Eval("RegionName")%></td>  
         <td><%# Eval("ZoneName")%></td>  
         <td><%# Eval("TerritoryName")%></td>  
         <td><%# Eval("FileNo")%></td>  
         <td><%# Eval("EmployeeName")%></td>  
         <td><%# Eval("Categorydesc")%></td>  
         <td><%# Eval("Productname")%></td>  
         <td><%# Eval("Specdesc")%></td>  
         <td><%# Eval("SaleQty")%></td>  
         <td><%# Eval("IncentiveRate")%></td>  
         <td><%# Eval("IncentiveValue")%></td>  
       </tr>  
     </ItemTemplate>  
   </asp:ListView>  
 </form>  
 <script src="jqury/jquery-1.11.3.min.js" type="text/javascript"></script>  
   <script src="jqury/jquery.dataTables.min.js" type="text/javascript"></script>  
   <script type="text/javascript">  
    $(document).ready(function () {  
      $('#example').DataTable();  
         });  
 </script>  
 </body>  
 </html>  

1:  Imports System.Data  
2:  Imports System.Data.SqlClient  
3:  Partial Class Default2  
4:    Inherits System.Web.UI.Page  
5:    Protected Sub form1_Load(sender As Object, e As System.EventArgs) Handles form1.Load  
6:     Dim objCommon As New clsCommon  
7:     Dim qryMain As String  
8:     qryMain = "exec LoadProductWithSaleEmp '','','',''"  
9:     Dim dt As DataTable = objCommon.GetDataTable(qryMain)  
10:     lstfinance.DataSource = dt  
11:     lstfinance.DataBind()  
12:    End Sub  
13:  End Class  

Edit,Update,Delete by Drop Down Foriegn key by Two table Listview

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,,BE>>>>>>>>>>>>>>>>>>>>>>>>....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BE_test
{
  public   class BECountry
    {
      public int CId {get; set;}
      public string Country { get; set; }
    }
}
---------------------------------------2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BE_test
{
    public class BEtest
    {
         public int  Id {get; set;}
         public string Name {get; set;}
         public string Address {get; set;}
         public string City {get; set;}
         public string Phoneno {get; set;}
         public int  CId {get; set;}
         public string Country { get; set; }
    }
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>DAl>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_test;
using System.Data.SqlClient;
using System.Data;

namespace DAl_test
{
     public class DALCountry
    {
        private string connect = MyConnectionString.path;
        public List<BECountry> show()
        {
            List<BECountry> list = new List<BECountry>();
            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand(MyProc.Name.spcount.ToString(), con);
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                con.Open();
                SqlDataReader sdr = cmd.ExecuteReader();
                if (sdr.HasRows)
                {
                    while (sdr.Read())
                    {
                        BECountry becountry = new BECountry();
                        becountry.CId = Convert.ToInt32(sdr["CId"]);
                        becountry.Country = Convert.ToString(sdr["Country"]);
                        list.Add(becountry);

                    }

                }



            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {

                con.Close();

            }

            return list;

        }
    }
}
------------------------------2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_test;
using System.Data;
using System.Data.SqlClient;

namespace DAl_test
{
    public class DAltest
    {
        private string connect = MyConnectionString.path;
        public List<BEtest> show()
        {
            List<BEtest> list = new List<BEtest>();
            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand(MyProc.Name.show.ToString(), con);
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                con.Open();
                SqlDataReader sdr = cmd.ExecuteReader();
                if (sdr.HasRows)
                {
                    while (sdr.Read())
                    {
                        BEtest BEtest = new BEtest();
                        BEtest.Id = Convert.ToInt32(sdr["Id"]);
                        BEtest.Name = Convert.ToString(sdr["Name"]);
                        BEtest.Address = Convert.ToString(sdr["Address"]);
                        BEtest.City = Convert.ToString(sdr["City"]);
                        BEtest.Phoneno = Convert.ToString(sdr["Phoneno"]);
                        BEtest.CId = Convert.ToInt32(sdr["CId"]);

                        list.Add(BEtest);

                    }

                }



            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {

                con.Close();

            }

            return list;

        }
        public void insert(BEtest be)
        {
         
            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand(MyProc.Name.spinsertinfo.ToString(), con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Name", be.Name);
            cmd.Parameters.AddWithValue("@Address", be.Address);
            cmd.Parameters.AddWithValue("@City", be.City);
            cmd.Parameters.AddWithValue("@Phoneno", be.Phoneno);
            cmd.Parameters.AddWithValue("@CId", be.CId);
            try
            {
                con.Open();
                 cmd.ExecuteNonQuery();
           
            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {

                con.Close();

            }

           

        }
        public void update(BEtest be)
        {

            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand(MyProc.Name.spupdateinfo.ToString(), con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Id", be.Id);
            cmd.Parameters.AddWithValue("@Name", be.Name);
            cmd.Parameters.AddWithValue("@Address", be.Address);
            cmd.Parameters.AddWithValue("@City", be.City);
            cmd.Parameters.AddWithValue("@Phoneno", be.Phoneno);
            cmd.Parameters.AddWithValue("@CId", be.CId);
            try
            {
                con.Open();
                cmd.ExecuteNonQuery();

            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {

                con.Close();

            }
        }
        public void delete(BEtest be)
        {

            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand(MyProc.Name.spdeleteinfo.ToString(), con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Id", be.Id);
         
            try
            {
                con.Open();
                cmd.ExecuteNonQuery();

            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {

                con.Close();

            }


        }
           
    }
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MyconnectionString>>>>>>>>>>>>>>>>>>>>>>>>>.....
'using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace DAl_test
{
    public class MyConnectionString
    {
         public static string path;
        static MyConnectionString()
        {
            path = ConfigurationManager.ConnectionStrings["Db"].ConnectionString;

        }
    }
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>My Proc?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAl_test
{
   public class MyProc
    {
       public enum Name
       {
           show, spcount, spinsertinfo, spupdateinfo, spdeleteinfo
       }
         
    }
}
?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>webconfig>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.......
<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
  <connectionStrings>
    <add name="Db" connectionString="Data Source=.;Initial Catalog=testtoday;Integrated Security=True" providerName="SystemSqlClient"/>
  </connectionStrings>
</configuration>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Bl>>>>>>>>>>>>>>>>>>>>>>>.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_test;
using DAl_test;

namespace Bl_test
{
    public class BLCountry
    {
        public List<BECountry> show()
        {
           return new DALCountry().show();
        }
    }
}
------------------------2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_test;
using DAl_test;

namespace Bl_test
{
    public class Bltest
    {
        public List<BEtest> show()
        {
            return new DAltest().show();
        }
        public void insert(BEtest be)
        {
            new DAltest().insert(be);
        }
        public void update(BEtest be)
        {
            new DAltest().update(be);
        }
        public void delete(BEtest be)
        {
            new DAltest().delete(be);
        }
    }
}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>test.aspx>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Webtest.test" %>

<!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>
    <style type="text/css">
        .style1
        {
            width: 100%;
            border-collapse: collapse;
            border-color: #99FF66;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ListView ID="ListVew1" runat="server" DataKeyNames="Id" OnItemEditing="ListView1_ItemEditing" OnItemUpdating="ListView1_ItemUpdating"
        OnItemDeleting="ListView1_ItemDeleting" OnItemCanceling="ListView1_Cancelling">
     
                 <LayoutTemplate>
                <table border="1">
                    <tr>
                        <td style="width: 100px">
                            Id
                        </td>
                        <td style="width: 100px">
                            Name
                        </td>
                        <td style="width: 100px">
                            Address
                        </td>
                        <td style="width: 200px">
                            City
                        </td>
                        <td style="width: 200px">
                            Phone
                        </td>
                        <td style="width: 200px">
                            Country
                        </td>
                        <td style="width: 200px">
                           Actions
                        </td>
                    </tr>
                </table>
                <div id="ItemPlaceholder" runat="server">
                </div>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <table border="1">
                    <tr>
                        <td style="width: 100px">
                            <%#Eval("Id")%>
                        </td>
                        <td style="width: 100px">
                            <%#Eval("Name") %>
                        </td>
                        <td style="width: 100px">
                            <%#Eval("Address") %>
                        </td>
                        <td style="width: 200px">
                            <%#Eval("City")%>
                        </td>
                        <td style="width: 200px">
                            <%#Eval("Phoneno")%>
                        </td>
                        <td style="width: 200px">
                            <%#Eval("Country")%>
                        </td>
                         <td style="width: 200px">
                     
                             <asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" />
                             <asp:Button ID="btnDelete" runat="server" Text="Delete" CommandName="Delete" OnClientClick="return confirm('do you want to delete?')" />
                         
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
            <EditItemTemplate>
              <table border="1">
                    <tr>
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("Id") %>'></asp:TextBox>
                        </td>
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%#Eval("Name") %>'></asp:TextBox>
                        </td>
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox3" runat="server" Text='<%#Eval("Address") %>'></asp:TextBox>
                        </td>
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox9" runat="server" Text='<%#Eval("City") %>'></asp:TextBox>
                        </td>
                        <td style="width: 200px">
                            <asp:TextBox ID="TextBox4" runat="server" Text='<%#Eval("Phoneno") %>'></asp:TextBox>
                        </td>
                        <td style="width: 200px">
                            <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true">
                            </asp:DropDownList>
                            <asp:HiddenField ID="hfClientId" runat="server" Value='<%#Eval("CId")%>' />
                        </td>
                         <td style="width: 200px">
                               <asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" />
                             <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" />
                        </td>
                    </tr>
                </table>
         
            </EditItemTemplate>
           
     
        </asp:ListView>


        <br />
        <br />
        <table class="style1">
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    Name:</td>
                <td>
                    <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    Address</td>
                <td>
                    <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    City</td>
                <td>
                    <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    Phone Number</td>
                <td>
                    <asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RF" runat="server" ErrorMessage="*" ControlToValidate="TextBox8"
                            ValidationGroup="Yes"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Only Alpha-Numeric"
                            Display="Dynamic" ControlToValidate="TextBox8" ValidationExpression="^[0-9\- \s]+$"
                            ValidationGroup="UP"> </asp:RegularExpressionValidator>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    Select Country</td>
                <td>
                    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
                        >
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                        ErrorMessage="*" ControlToValidate="DropDownList1" ></asp:RequiredFieldValidator>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:Button ID="btnSave" runat="server" EnableTheming="True" Text="Save"
                        onclick="btnSave_Click" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>


    </div>
    </form>
</body>
</html>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>test.asps.cs>>>>>>>>>>>>>>>>>>>>>>>>>>......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bl_test;
using BE_test;

namespace Webtest
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                dllupdate();
                pp();
             
            }
           
        }
        public void pp() {
            List<BEtest> list = new Bltest().show();
            foreach (BEtest item in list)
            {
                item.Country = new BLCountry().show().Single(id => id.CId == item.CId).Country;
            }
            ListVew1.DataSource = list;
            ListVew1.DataBind();
         
        }
     
        public void dllupdate()
        {
            DropDownList1.DataSource = new BLCountry().show();
            DropDownList1.DataTextField = "Country";
            DropDownList1.DataValueField = "CId";
            DropDownList1.DataBind();
            DropDownList1.Items.Insert(0, "----select----");



        }

     

        protected void btnSave_Click(object sender, EventArgs e)
        {
            BEtest be = new BEtest();
            be.Name = TextBox5.Text;
            be.Address = TextBox6.Text;
            be.City = TextBox7.Text;
            be.Phoneno = TextBox8.Text;
            be.CId = Convert.ToInt32(DropDownList1.SelectedValue);
            new Bltest().insert(be);
            pp();
        }
        protected void ListView1_ItemEditing(object sender, ListViewEditEventArgs e)
        {
            ListVew1.EditIndex = e.NewEditIndex;
            pp();
            ListViewDataItem item = ListVew1.Items[ListVew1.EditIndex] as ListViewDataItem;
            DropDownList ddlClients = item.FindControl("DropDownList2") as DropDownList;
            HiddenField hfClientId = item.FindControl("hfClientId") as HiddenField;
            ddlClients.DataSource = new BLCountry().show();
            ddlClients.DataTextField = "Country";
            ddlClients.DataValueField = "CId";
            ddlClients.DataBind();
            ddlClients.SelectedValue = hfClientId.Value;
           
        }

       
        protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
        {
            string lId = ListVew1.DataKeys[e.ItemIndex].Value.ToString();
            TextBox detail2 = ListVew1.Items[e.ItemIndex].FindControl("TextBox2") as TextBox;
            TextBox detail3 = ListVew1.Items[e.ItemIndex].FindControl("TextBox3") as TextBox;
            TextBox detail4 = ListVew1.Items[e.ItemIndex].FindControl("TextBox4") as TextBox;
            TextBox detail5 = ListVew1.Items[e.ItemIndex].FindControl("TextBox9") as TextBox;
            BEtest bes = new BEtest();
            bes.Id = Convert.ToInt32(lId);
            bes.Name = detail2.Text;
            bes.Address = detail3.Text;
            bes.City = detail5.Text;
            bes.Phoneno = detail4.Text;
            bes.CId = Convert.ToInt32(((DropDownList)ListVew1.Items[e.ItemIndex].FindControl("DropDownList2")).SelectedValue);
            new Bltest().update(bes);
            ListVew1.EditIndex = -1;
            pp();
        }

        protected void ListView1_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
            string listId = ListVew1.DataKeys[e.ItemIndex].Value.ToString();
            BEtest bem = new BEtest();
            bem.Id = Convert.ToInt32(listId);
            new Bltest().delete(bem);
            pp();


        }

        protected void ListView1_Cancelling(object sender, ListViewCancelEventArgs e)
        {
            ListVew1.EditIndex = -1;
            pp();

        }

   
    }
}

Insert, update, delete by Listview

>>>>>>>>>>>>>>>>>>>>>>>>>>>GETCoNneCTION.cs>>>>>>>>>>>>>>>>>>>>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;


namespace ConnectionStringClass
{
    public class GetConnection
    {
        public static string path;
        static GetConnection()
        {
            path = ConfigurationManager.ConnectionStrings["RESERVATION"].ConnectionString;

        }
    }
}



<<<<<<<<<<<<<<<<<<<<<BE.cs>>>>>>>>>>>>>>>>>>>>>>>>>.......


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BE_Reservation
{
    public class BE
    {
        public int id { get; set; }
        public string name { get; set; }
        public string address { get; set; }
        public string dis { get; set; }
    }
}

>.>>>>>>>>>>>>>>>>>>DAL.cs>>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using BE_Reservation;
using ConnectionStringClass;


namespace DAL_Reservation
{
    public class DAL
    {
        private string connect = GetConnection.path;
        public List<BE> show()
        {
            List<BE> list = new List<BE>();
            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand("pogo", con);
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                con.Open();
                SqlDataReader sdr = cmd.ExecuteReader();
                if (sdr.HasRows)
                {
                    while (sdr.Read())
                    {
                        BE be = new BE();
                        be.id = Convert.ToInt32(sdr["id"]);
                        be.name = Convert.ToString(sdr["name"]);
                        be.address = Convert.ToString(sdr["address"]);
                        be.dis = Convert.ToString(sdr["dis"]);
                        list.Add(be);

                    }





                }



            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {

                con.Close();

            }

            return list;

        }

        public void UpdateReserver(BE be)
        {

            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand("spupdate", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@id", be.id);
            cmd.Parameters.AddWithValue("@name", be.name);
            cmd.Parameters.AddWithValue("@address", be.address);
            cmd.Parameters.AddWithValue("@dis", be.dis);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {
                con.Close();
            }

        }


        public void DeleteR(BE be)
        {

            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand("spdelete ", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@id", be.id);
         

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {
                con.Close();
            }

        }
        public void InsertR(BE be)
        {

            SqlConnection con = new SqlConnection(connect);
            SqlCommand cmd = new SqlCommand("spInsert ", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@name", be.name);
            cmd.Parameters.AddWithValue("@address", be.address);
            cmd.Parameters.AddWithValue("@dis", be.dis);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception exe)
            {
                throw exe;
            }
            finally
            {
                con.Close();
            }

        }


    }
}


>>>>>>>>>>>>>>>>>>>>>>>>>>>>BL.cs>>>>>>>>>>>>>>>>>>>>>>>>>>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_Reservation;
using DAL_Reservation;

namespace BL_Reservation
{
    public class BL
    {
 
   public List<BE> show()
    {
        return new DAL().show();
    }
   public void UpdateReserver(BE be)
   {
       new DAL().UpdateReserver(be);
   }
   public void DeleteR(BE be)
   {
       new DAL().DeleteR(be);
   }
   public void InsertR(BE be)
   {
       new DAL().InsertR(be);
   }

    }
    }



>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>WEBFoRm1.apx>>>>>>>>>>>>>>>>>>>>>>>>>


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Sale.WebForm1"  EnableEventValidation="false"  %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="id" OnItemEditing="ListView1_ItemEditing" OnItemUpdating="ListView1_ItemUpdating"
        OnItemDeleting="ListView1_ItemDeleting" OnItemCanceling="ListView1_Cancelling" InsertItemPosition="LastItem" OnItemInserting="ListView1_ItemInserting">
            <LayoutTemplate>
                <table border="1">
                    <tr>
                        <td style="width: 100px">
                            Id
                        </td>
                        <td style="width: 100px">
                            Name
                        </td>
                        <td style="width: 100px">
                            Address
                        </td>
                        <td style="width: 200px">
                            dis
                        </td>
                        <td style="width: 200px">
                           Actions
                        </td>
                    </tr>
                </table>
                <div id="ItemPlaceholder" runat="server">
                </div>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <table border="1">
                    <tr>
                        <td style="width: 100px">
                            <%#Eval("id") %>
                        </td>
                        <td style="width: 100px">
                            <%#Eval("name") %>
                        </td>
                        <td style="width: 100px">
                            <%#Eval("address") %>
                        </td>
                        <td style="width: 200px">
                            <%#Eval("dis") %>
                        </td>
                         <td style="width: 200px">
                     
                            <asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" />
                             <asp:Button ID="btnDelete" runat="server" Text="Delete" CommandName="Delete" />
                           
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
            <EditItemTemplate>
              <table border="1">
                    <tr>
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("id") %>'></asp:TextBox>
                        </td>
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%#Eval("name") %>'></asp:TextBox>
                        </td>
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox3" runat="server" Text='<%#Eval("address") %>'></asp:TextBox>
                        </td>
                        <td style="width: 200px">
                            <asp:TextBox ID="TextBox4" runat="server" Text='<%#Eval("dis") %>'></asp:TextBox>
                        </td>
                         <td style="width: 200px">
                            <asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" />
                             <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" />
                        </td>
                    </tr>
                </table>
           
            </EditItemTemplate>
            <InsertItemTemplate>
            <table border="1">
                    <tr>
                     
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
                        </td>
                        <td style="width: 100px">
                            <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
                        </td>
                        <td style="width: 200px">
                            <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
                        </td>
                        <td style="width: 200px">
                            <asp:Button ID="btnInsert" runat="server" Text="Insert" CommandName="Insert" />
                        </td>
                    </tr>
                </table>
           
            </InsertItemTemplate>
        </asp:ListView>

    </div>

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



>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>webform1.aspx.cs>>>>>>>>>>>>>>>>>>>>>>>>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BE_Reservation;
using BL_Reservation;

namespace Sale
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                databind();
            }
        }

        protected void ListView1_ItemEditing(object sender, ListViewEditEventArgs e)
        {
            ListView1.EditIndex = e.NewEditIndex;
            databind();
        }

        protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
        {
            TextBox txtItems1 = (e.Item.FindControl("TextBox5")) as TextBox;
            TextBox txtItems2 = (e.Item.FindControl("TextBox6")) as TextBox;
            TextBox txtItems3 = (e.Item.FindControl("TextBox7")) as TextBox;

                BE bem = new BE();
                bem.name = txtItems1.Text;
                bem.address = txtItems2.Text;
                bem.dis = txtItems3.Text;
                new BL().InsertR(bem);
                txtItems1.Text = "";
                databind();
        }
        protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
        {
            string lId = ListView1.DataKeys[e.ItemIndex].Value.ToString();
            TextBox detail2 = ListView1.Items[e.ItemIndex].FindControl("TextBox2") as TextBox;
            TextBox detail3 = ListView1.Items[e.ItemIndex].FindControl("TextBox3") as TextBox;
            TextBox detail4 = ListView1.Items[e.ItemIndex].FindControl("TextBox4") as TextBox;
            BE bes = new BE();
            bes.id = Convert.ToInt32(lId);
            bes.name = detail2.Text;
            bes.address = detail3.Text;
            bes.dis = detail4.Text;

            new BL().UpdateReserver(bes);
            ListView1.EditIndex = -1;
            databind();
        }

        protected void ListView1_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
            string listId = ListView1.DataKeys[e.ItemIndex].Value.ToString();
            BE bem = new BE();
            bem.id = Convert.ToInt32(listId);
            new BL().DeleteR(bem);
            databind();
       
       
        }

        protected void ListView1_Cancelling(object sender, ListViewCancelEventArgs e)
        {
            ListView1.EditIndex = -1;
            databind();
       
        }

        public void databind()
        {
            ListView1.DataSource = new BL().show();
            ListView1.DataBind();
        }

    }
}

alter proc spGetValue
@Id nvarchar(50),
@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin
UPDATE Tbl_dis
   SET   [Education]=@Education,
         [Institute]=@Institute,
        [City]=@City,
       [Job]=@Job
 WHERE @Id=Id
 end



>>>>>>>>>>>>>>>>>>>>>>>UPDATE >><<<<<<<<<<<<<<<
alter proc spGetValue 1,'dhsj','hjsajd','hgaj','hgsdhga'
@Id int,
@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin
UPDATE Tbl_dis
   SET   [Education]=@Education,
         [Institute]=@Institute,
        [City]=@City,
       [Job]=@Job
 WHERE @Id=Id
 end


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>INSERT >>>>>>>>>>>>>>>>>>>>>>..


alter proc spGetValue2 'Bcom','national','toba','tch'

@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin


INSERT INTO Tbl_dis
           ([Education]
           ,[Institute]
           ,[City]
           ,[Job])
     VALUES
           (@Education
           ,@Institute
           ,@City
           ,@Job)
end


>>>>>>>>>>>>>>>>>>>>>>......delete>>>>>.................]
\
create proc spvalue '2'
@Id int
as
begin

DELETE FROM Tbl_dis
      WHERE Id=@Id
end