Wednesday, 31 October 2012

.Net Framework Features, from.Net 2.0 to 4.5



  • Introduction
  • .Net Framework 2.0 Features
    • ADO.NET 2.0
    • SQL Server data provider (SqlClient)
    • XML
    • .NET Remoting
    • ASP.NET 2.0
  • .Net Framework 3.0/3.5 Features
    • Windows Presentation Foundation (WPF)
    • Windows Communication Foundation (WCF)
    • Windows Workflow Foundation (WWF)
    • Windows Card Space (WCS)
    • Core New Features and Improvements
      • Auto Implemented
      • Implicit Typed local variable
      • Implicitly Typed Arrays
      • Anonymous Types
      • Extension Methods(3.5 new feature)
      • Object and Collection Initializers
      • Lambda Expressions
  • .Net Framework 4.0Features
    •     Application Compatibility and Deployment
    •     Core New Features and Improvements
      • BigInteger and Complex Numbers
      • Tuples
      • Covariance and Contravariance
      • Dynamic Language Runtime
    •     Managed Extensibility Framework
    •     Parallel Computing
    •     Networking
    •     Web
    •     Client
    •     Data
    •     Windows Communication Foundation
    •     Windows Workflow Foundation
  • .Net Framework 4.5 Features
    • .NET for Windows Store Apps
    • Portable Class Libraries
    • Core New Features and Improvements
    • Tools
    • Parallel Computing
    • Web
    • Windows Presentation Foundation (WPF)
    • Windows Communication Foundation (WCF)
    • Windows Workflow Foundation (WF)
  • Conclusion


Introduction

This article discusses the features introduced in Microsoft .net framework 2.0, 3.0, 3.5, 4.0 and newly introduced 4.5 framework.

.Net Framework 2.0 Features



ADO.NET

New features in ADO.NET include support for user-defined types (UDT), asynchronous database operations, XML data types, large value types, snapshot isolation, and new attributes that allow applications to support multiple active result sets (MARS) with SQL Server 2005

ASP.NET


The Microsoft .NET Framework 2.0 includes significant enhancements to all areas of ASP.NET. For Web page development, new controls make it easier to add commonly used functionality to dynamic Web pages. New data controls make it possible to display and edit data on an ASP.NET Web page without writing code. An improved code-behind model makes developing ASP.NET pages easier and more robust. Caching features provide several new ways to cache pages, including the ability to build cache dependency on tables in a SQL Server database.
ASP.NET accommodates a wide variety of browsers and devices. By default, controls render output that is compatible with XHTML 1.1 standards. You can use device filtering to specify different property values on the same control for different browsers.

.NET Remoting

.NET Framework Remoting now supports IPv6 addresses and the exchange of generic types. The classes in the System.Runtime.Remoting.Channels.Tcp namespace support authentication and encryption using the Security Support Provider Interface (SSPI). Classes in the new System.Runtime.Remoting.Channels.Ipc namespace allow applications on the same computer to communicate quickly without using the network. Finally, you can now configure the connection cache time-out and the number of method retries, which can improve the performance of network load-balanced remote clusters.

XML

The new System.Xml.XmlReaderSettings class allows to specify the type of verifications which must be done when using a subclass of XmlReader to read XML data.
It is now possible to partially validate a DOM tree loaded within an instance of XmlDocument.
It is now possible to modify a DOM tree stored in an XmlDocument instance through the XPathNavigator cursor API.

.Net Framework 3.0/3.5 Features


Windows Presentation Foundation (WPF)

Windows Presentation Foundation (WPF) is a next-generation presentation system for building Windows client applications. The core of WPF is a resolution-independent and vector-based rendering engine that is built to take advantage of modern graphics hardware.
 WPF extends the core with a comprehensive set of application-development features that include Extensible Application Markup Language (XAML), controls, data binding, layout, 2-D and 3-Dgraphics, animation, styles, templates, documents, media, text, and typography. WPF is included in the Microsoft .NET Framework, so you can build applications that incorporate other elements of the .NET Framework class library.
To support some of the more powerful WPF capabilities and to simplify the programming experience, WPF includes additional programming constructs that enhance properties and events: dependency properties and routed events.

Windows Communication Foundation (WCF)


Windows Communication Foundation (WCF) is Microsoft’s unified programming model for building service-oriented applications. WCF allows you to build all kinds of distributed applications including 'traditional' Web Services so that your services support SOAP and will therefore be compatible with older .NET (and other) technologies. WCF is not just about pure SOAP over the wire - you can work with an Info set, and create a binary representation of your SOAP message that can then be sent along with your choice of protocol. This is for those who are particularly concerned about performance and have traditionally turned to .NET remoting.

Windows Workflow Foundation (WWF)


Windows Workflow Foundation, a core component of .NET Framework 3.0, provides a programming model, run-time engine, and tools for building workflow applications
A workflow is created and maintained by the workflow run-time engine. There can be several workflow engines within an application domain, and each workflow engine can support multiple workflows running concurrently. The run-time enables idle workflows to be unloaded from memory, persisted to a store, and reloaded whenever input is received.
Workflows can be authored in code, XAML markup, or a combination of both, known as code-separation, which is similar to the ASP.NET mode
Windows CardSpace (WCS):

Windows CardSpace (InfoCard) is a Digital Identity to online services. Digital Identity means how user will electronically represent them. Like as a debit/credit card each card has digital identity and password. If any user go to use the site on internet then he enter their username and password, for identity, but this is not secure.  To reduce these types of problems WCS works.
WCS (originally called Info Card) helps people keep track of their digital identities as distinct information cards. If a Web site accepts WCS logins, users attempting to log in to that site will see a WCS selection. By choosing a card, users also choose a digital identity that will be used to access this site. CardSpace and the new supporting technologies will change how you authenticate into an application, whether it sits on the Web, your phone, or your desktop.

Core New Features and Improvements


Some core new features and improvements are implemented in .Net 3.0/3.5

1. Auto Implemented Property

2. Implicit Typed local variable

3. Implicitly Typed Arrays

4. Anonymous Types

5. ExtensionMethods (3.5 new feature)

6. Object and Collection Initializers

7. Lambda Expressions



.Net Framework 4.0 Features



    Application Compatibility and Deployment

The .NET Framework 4 is highly compatible with applications that are built with earlier .NET Framework versions, except for some changes that were made to improve security, standards compliance, correctness, reliability, and performance.
The .NET Framework 4 does not automatically use its version of the common language runtime to run applications that are built with earlier versions of the .NET Framework. To run older applications with .NET Framework 4, you must compile your application with the target .NET Framework version specified in the properties for your project in Visual Studio, or you can specify the supported runtime with the <supportedRuntime> Element in an application configuration file.

    Core New Features and Improvements

Some new features are introduced in .net framework 4.0
The following sections describe new features and improvements provided by the common language runtime and the base class libraries.

1.     BigInteger and Complex Numbers

2.     Tuples

3.     Covariance and Contravariance

4.     Dynamic Language Runtime


    Managed Extensibility Framework

The Managed Extensibility Framework (MEF) is a new library in the .NET Framework 4 that helps you build extensible and composable applications. MEF enables you to specify points where an application can be extended, to expose services to offer to other extensible applications and to create parts for consumption by extensible applications.
It also enables easy discoverability of available parts based on metadata, without the need to load the assemblies for the parts.

    Parallel Computing

The .NET Framework 4 introduces a new programming model for writing multithreaded and asynchronous code that greatly simplifies the work of application and library developers. The new model enables developers to write efficient, fine-grained, and scalable parallel code in a natural idiom without having to work directly with threads or the thread pool. The new System.Threading.Tasks namespace and other related types support this new model

Web

ASP.NET version 4 introduces new features in the following areas:
  • Core services, including a new API that lets you extend caching, support for compression for session-state data, and a new application preload manager (autostart feature).
  • Web Forms, including more integrated support for ASP.NET routing, enhanced support for Web standards, updated browser support, new features for data controls, and new features for view state management.
  • Web Forms controls, including a new Chart control.
  • MVC, including new helper methods for views, support for partitioned MVC applications, and asynchronous controllers.
  • Dynamic Data, including support for existing Web applications, support for many-to-many relationships and inheritance, new field templates and attributes, and enhanced data filtering.
  • Microsoft Ajax, including additional support for client-based Ajax applications in the Microsoft Ajax Library.
  • Visual Web Developer, including improved IntelliSense for JScript, new auto-complete snippets for HTML and ASP.NET markup, and enhanced CSS compatibility.
  • Deployment, including new tools for automating typical deployment tasks.
  • Multi-targeting, including better filtering for features that are not available in the target version of the .NET Framework

Windows Presentation Foundation (WPF) Features in 4.0

Windows Presentation Foundation (WPF) version 4 contains changes and improvements in the following areas:
  • New controls, including Calendar, Data Grid, and Date Picker.
  • VisualStateManager supports changing states of controls.
  • Touch and Manipulation enables you to create applications that receive input from multiple touches simultaneously on Windows 7.
  • Graphics and animation supports layout rounding, Pixel Shader version 3.0, cached composition, and easing functions.
  • Text has improved text rendering and supports customizing the caret color and selection color in text boxes.
  • Binding is supported on the Command property of an InputBinding, dynamic objects, and the Text property.
  • XAML browser applications (XBAPs) support communication with the Web page and support full-trust deployment.
  • New types in the System.Windows.Shell namespace enable you to communicate with the Windows 7 taskbar and pass data to the Windows shell.
  • The WPF and Silverlight Designer in Visual Studio 2010 has various designer improvements to help create WPF or Silverlight applications.

 

Windows Communication FoundationFeatures in 4.0

Windows Communication Foundation (WCF) provides the following improvements:
  • Configuration-based activation: Removes the requirement for having an .svc file.
  • System.Web.Routing integration: Gives you more control over your service's URL by allowing the use of extensionless URLs.
  • Multiple IIS site bindings support: Allows you to have multiple base addresses with the same protocol on the same Web site.
  • Routing Service: Allows you to route messages based on content.
  • Support for WS-Discovery: Allows you to create and search for discoverable services.
  • Standard endpoints: Predefined endpoints that allow you to specify only certain properties.
  • Workflow services: Integrates WCF and WF by providing activities to send and receive messages, the ability to correlate messages based on content, and a workflow service host.

Windows Workflow FoundationFeatures in 4.0

Windows Workflow Foundation (WF) provides improvements in the following areas:
  • Improved workflow activity model: The Activity class provides the base abstraction of workflow behavior.
  • Rich composite activity options: Workflows benefit from new flow-control activities that model traditional flow-control structures, such as Flowchart, TryCatch, and Switch<T>.
  • Expanded built-in activity library: New features of the activity library include new flow-control activities, activities for manipulating member data, and activities for controlling transactions.


.Net Framework 4.5 Features

 .NET for Windows Store Apps

Windows Store apps are designed for specific form factors and leverage the power of the Windows operating system. A subset of the .NET Framework 4.5 is available for building Windows Store apps for Windows by using C# or Visual Basic.

Portable Class Libraries

The Portable Class Library project in Visual Studio 2012 enables you to write and build managed assemblies that work on multiple .NET Framework platforms. Using a Portable Class Library project, you choose the platforms (such as Windows Phone and .NET for Windows Store apps) to target.

ASP.NET 4.5

ASP.NET 4.5 includes the following new features:
  • Support for new HTML5 form types.
  • Support for model binders in Web Forms. These let you bind data controls directly to data-access methods, and automatically convert user input to and from .NET Framework data types.
  • Support for unobtrusive JavaScript in client-side validation scripts.
  • Improved handling of client script through bundling and minification for improved page performance.
  • Integrated encoding routines from the AntiXSS library (previously an external library) to protect from cross-site scripting attacks.
  • Support for WebSockets protocol.

 

Windows Presentation Foundation (WPF) Features in 4.5

In the .NET Framework 4.5, Windows Presentation Foundation (WPF) contains changes and improvements in the following areas:
  • The new Ribbon control, which enables you to implement a ribbon user interface that hosts a Quick Access Toolbar, Application Menu, and tabs.
  • The new INotifyDataErrorInfo interface, which supports synchronous and asynchronous data validation.
  • New features for the VirtualizingPanel and Dispatcher classes.
  • Improved performance when displaying large sets of grouped data, and by accessing collections on non-UI threads.
  • Data binding to static properties, data binding to custom types that implement the ICustomTypeProvider interface, and retrieval of data binding information from a binding expression.
  • Repositioning of data as the values change (live shaping).
  • Ability to check whether the data context for an item container is disconnected.
  • Ability to set the amount of time that should elapse between property changes and data source updates.
  • Improved support for implementing weak event patterns. Also, events can now accept markup extensions.

 

Windows Communication Foundation (WCF) Features in 4.5

In the .NET Framework 4.5, the following features have been added to make it simpler to write and maintain Windows Communication Foundation (WCF) applications:
  • Simplification of generated configuration files.
  • Support for contract-first development.
  • Ability to configure ASP.NET compatibility mode more easily.
  • Changes in default transport property values to reduce the likelihood that you will have to set them.
  • Updates to the XmlDictionaryReaderQuotas class to reduce the likelihood that you will have to manually configure quotas for XML dictionary readers.
  • Validation of WCF configuration files by Visual Studio as part of the build process, so you can detect configuration errors before you run your application.
  • New asynchronous streaming support.
  • New HTTPS protocol mapping to make it easier to expose an endpoint over HTTPS with Internet Information Services (IIS).
  • Ability to generate metadata in a single WSDL document by appending ?singleWSDL to the service URL.
  • Websockets support to enable true bidirectional communication over ports 80 and 443 with performance characteristics similar to the TCP transport.
  • Support for configuring services in code.
  • XML Editor tooltips.

Windows Workflow Foundation (WF) Features in 4.5

Several new features have been added to Windows Workflow Foundation (WF) in the .NET Framework 4.5. These new features include:
  • State machine workflows, which were first introduced as part of the .NET Framework 4.0.1 (.NET Framework 4 Platform Update 1). This update included several new classes and activities that enabled developers to create state machine workflows. These classes and activities were updated for the .NET Framework 4.5 to include:
    • The ability to set breakpoints on states.
    • The ability to copy and paste transitions in the workflow designer.
    • Designer support for shared trigger transition creation.

 Happy Programming ! !

If you have any query mail me to Sujeet.bhujbal@gmail.com     


Regards

Sujeet Bhujbal

------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------



Wednesday, 17 October 2012

How to Improve Performance of Asp.net web site.


Hi friends,

In this article I will tell you how to improve performance of our asp.net website. There is very small setting but it improves huge performance.

In the web.config file you can do the following setting

1) Set debug=false under compilation as follows:

<compilation default Language="c#" debug="false">



2) Use Server.Transfer instead of Response.Redirect.


3) Always check Page.IsValid when using Validator Controls


4) Use Foreach loop instead of For loop for String Iteration.


5) Use Client-Side Validation. (but not all the time you have to validate even on the server side)


6) Check “Page.IsPostBack”. To avoid repetition code execution.


7) GIF and PNG are similar, but PNG typically produces a lower file size. (True, but some browsers not supporting PNG format)


8) Use the AppOffline.htm when updating binaries


9) Turn off Tracing unless until required. (by default it's off, use on the pages where it's required)

<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>



 Some times after doing this setting also ASP.NET Page is very slow. What will you do to make it fast?   

1. Find out which is slow, is it the application or the database : If the page is executing SQL queries or stored procedures, run those on the database and check how long do they take to run. If the queries are taking most of the time, then you know you have to tune the queries for better performance. To tune the queries, there are several ways and I have listed some of them below.
   a) Check if there are indexes to help the query
   b) Select only the required columns, avoid   Select *.
   c) Check if there is a possibility to reduce the number of joins
   d) If possible use NO LOCK on your select statements
   e) Check if there are cursors and if you can replace them with joins

2. If the queries are running fast, then we know it is the application code that is causing the slowness. Isolate the page event that is causing the issue by turning tracing on. To turn tracing on, set Trace="true" in the page directive. Once you have tracing turned on you should see trace information at the bottom of the page as shown in the image below. In this case Page Load event is taking the maximum time. So we know, the code in Page_Load event is causing the issue. Once you look at the code, you should be able to nail down the issue.




  Happy Programming ! !

If you have any query mail me to Sujeet.bhujbal@gmail.com     


Regards

Sujeet Bhujbal

------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------

Saturday, 6 October 2012

Check whether Silverlight is installed in your system or not


Check whether Silverlight is installed in your system or not

Hi Friends,

In the below article i will tell you how to check whether silverlight is installed in your system or not.


Copy the below code and paste into the blank notepad file and save as "HTML" extension
after running the page click on Check Silverlight link.

<html>
<head>
<script language="javascript">
function ShowMessage()
{
 if(
checkSilverlight
()==true)
 {
  alert("SilverLight installed.");
 }
 else
 {
  alert("SilverLight Not installed.");
 }
}

function checkSilverlight()
{
var browser = navigator.appName; // Get browser
varsilverlightInstalled = false;
if (browser == 'Microsoft Internet Explorer')
{
    try
    {
        varslControl = new ActiveXObject('AgControl.AgControl');
        silverlightInstalled = true;


    }
    catch (e)
    {
        // Error. Silverlight not installed.
    }
}
else
{
    // Handle Netscape, FireFox, Google chrome etc
    try
    {
        if (navigator.plugins["Silverlight Plug-In"])
        {
            silverlightInstalled = true;
        }
    }
    catch (e)
    {
        // Error. Silverlight not installed.
    }
}
return silverlightInstalled;
//alert(silverlightInstalled);
}
</script>
</head>
<body>
<a href="javascript:void(ShowMessage())">Check Silverlight</a>
</body>
</html>


 Happy Programming ! !

If you have any query mail me to Sujeet.bhujbal@gmail.com     


Regards

Sujeet Bhujbal

------------------------------------------------------------------------------------------------------------











------------------------------------------------------------------------------------------------------------


Monday, 1 October 2012

WCF Example for Inserting and Displaying Data from SQL Server Database Using WCF Service in ASP.NET

Introduction

In this article I will show you a practical example of a WCF service for inserting,deleting and displyaing data  using ASP.NET. 

Download Source Code



Using the code 

For inserting data into a database using a WCF service in ASP.NET, we have to do the following steps:
  • Create a WCF service. 
  • Create a Web based application. 
  •  
Part 1: Create a WCF Service
  1. Open Visual Studio 2010 
Step 1 : Select the new Empty Solution and Give name WCFProject   



Step 2 : Then Add new Class Library Project and  Give name SaleClassLibrary
Step 3:  Then Add reference of System.ServiceModel and System.Runtime.Serailization in to that project
Step 4: Then  Add new Interface ISaleService

//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;


 [ServiceContract]
    interface ISaleService
    {
        [OperationContract]
         bool InsertCustomer(Customer obj);

        [OperationContract]
        List<Customer> GetAllCustomer();


        [OperationContract]
        bool DeleteCustomer(int Cid);


        [OperationContract]
        bool UpdateCustomer(Customer obj);
       
    }

  [DataContract]
   public class Customer
    {
        [DataMember]
        public int CustomerID;
        [DataMember]
        public string CustomerName;       
        [DataMember]
        public string Address;
        [DataMember]
        public string EmailId;
    }
Step  5 : And write the following code in the SaleService.cs file: 
SaleService.cs page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;


public class SaleService : ISaleService
    {
        public bool InsertCustomer(Customer obj)
        {
            cutomerList.Add(obj);
            return true;
        }

        public List<Customer> GetAllCustomer()
        {
            return cutomerList;

        }

        public bool DeleteCustomer(int Cid)
        {
            var item = cutomerList.First(x => x.CustomerID == Cid);

            cutomerList.Remove(item);
            return true;
        }

        public bool UpdateCustomer(Customer obj)
        {
            var list = cutomerList;
            cutomerList.Where(p => p.CustomerID == obj.CustomerID).Update(p => p.CustomerName = obj.CustomerName);
            return true;
        }


      public static  List<Customer> cutomerList = new List<Customer>()
         {
        new Customer {CustomerID = 1, CustomerName="Sujeet", Address="Pune", EmailId="test@yahoo.com" },
        new Customer {CustomerID = 2, CustomerName="Rahul", Address="Pune", EmailId="test@yahoo.com" },
        new Customer {CustomerID = 3, CustomerName="Mayur", Address="Pune", EmailId="test@yahoo.com"}
         };

      
    }
Step 6 :  Build your Class library 
 Step 7 : Add New Empty Asp.net Project into that Solution  give name SaleServiceHost









Step 8 : Add reference of Classlibrary Project to that SaleServiceHost  Asp.net Project 
Step 9 : Add New Item WCF Service in that SaleServiceHost Asp.net Project and Give Name SaleService.  



Step 10:  Right Click on that SaleService.svc and select view Markup



 Change the Service Name from that markup 
<%@ ServiceHost Language="C#" Debug="true" Service="SaleClassLibrary.SaleService"  %>
Step 11 : And Build the solution and  SaleServiceHost  set as startup Project and SaleService.svc set as startup page
In this way your WCF service builds successfully. 
Part 2: Create a Web Based Application (Client)
Now create your client application in your system:
  1. Create a Website
  2. Add Service Reference http://localhost:53544/SaleService.svc?wsdl to a Web Application.
  3. Select your Website.
  4. Right click on it, Add Service Reference, then enter your Service URL and click Go.
  5. Give the name for your service SaleService -> OK.

  1. Then automatically a proxy will be created in your client system.
  2. Write the following code in your source code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
      <h2>
        Welcome to Sale Service</h2><table class="style1">
            <tr>
                <td style="text-align: right">
                    Enter name</td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Address</td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Email ID</td>
                <td>
                    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Save" />
                </td>
            </tr>
        </table>
   
<p>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True"  DataKeyNames="CustomerID,CustomerName"
            AllowSorting="True" AutoGenerateDeleteButton="True"
            onrowdeleting="GridView1_RowDeleting">
        </asp:GridView>
</p>
    <p>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </form>
    </body>
</html>
  1. Add your service reference on the top.
using SaleService;
  1. Then create an object for Service Reference and use that object to call the methods from your service.
  2. Write the following code in your aspx.cs file.
Default.aspx.cs page:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using ServiceReference1;

public partial class _Default : System.Web.UI.Page
{
    SaleService.SaleServiceClient proxy;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                 proxy=new SaleService.SaleServiceClient();
                GridView1.DataSource=proxy.GetAllCustomer();
                GridView1.DataBind();
            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            proxy = new SaleService.SaleServiceClient();
            SaleService.Customer objcust = new SaleService.Customer() { CustomerID=5, CustomerName=TextBox1.Text,
            Address=TextBox2.Text,EmailId=TextBox3.Text  };

            proxy.InsertCustomer(objcust);

            GridView1.DataSource = proxy.GetAllCustomer();
            GridView1.DataBind();
            Label1.Text = "Record Saved Successfully";
        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int userid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values["CustomerID"].ToString());
            proxy = new SaleService.SaleServiceClient();

            bool check = proxy.DeleteCustomer(userid);
              Label1.Text = "Record Deleted Successfully";
              GridView1.DataSource = proxy.GetAllCustomer();
              GridView1.DataBind();
        }
}
By using this you have successfully inserted data in the database and you have also shown this in the grid view.

Please find attached code for more information.

!! Happy Programming !!
 Don’t forget to leave your feedback and comments below! If you have any query,

Thanks
Sujeet