Simple insert and Gridview in webservices

Simple Insert in webservices:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;

namespace webservices
{
    /// <summary>
    /// Summary description for sample
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class sample : System.Web.Services.WebService
    {


        [WebMethod]
        public string insert(string name,string password)
        {
            string st;
            SqlConnection con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=TRIESTEN-PC");
            con.Open();
            SqlCommand cmd = new SqlCommand("sp_register", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@name",name);
            cmd.Parameters.AddWithValue("@password", password);
           int n= cmd.ExecuteNonQuery();
           if (n > 0)
           {
               st = "0";
           }
           else
           {
               st = "1";
           }
           con.Close();

           return st;

           
        }
}

}


Webform.aspx
<div>
        <asp:TextBox ID="txtuser" runat="server" ></asp:TextBox>
        <asp:TextBox ID="txtpass" runat="server" ></asp:TextBox>
        <asp:Button ID="bt" runat="server" Text="Save" OnClick="bt_Click" />
   
    </div>


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 System.Data;


namespace webservices
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        localhost.sample lo = new localhost.sample();
//webservices path
       
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void bt_Click(object sender, EventArgs e)
        {
           string st= lo.insert(txtuser.Text, txtpass.Text);
           if (st == "0")
           {
               Response.Write("insert sucess");
           }
        }
    }
}

Simple Gridview in webservices
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;

namespace webservices
{
    /// <summary>
    /// Summary description for sample
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class sample : System.Web.Services.WebService
    {

        [WebMethod]
        public string insert(string name,string password)
        {
            string st;
            SqlConnection con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=TRIESTEN-PC");
            con.Open();
            SqlCommand cmd = new SqlCommand("sp_register", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@name",name);
            cmd.Parameters.AddWithValue("@password", password);
           int n= cmd.ExecuteNonQuery();
           if (n > 0)
           {
               st = "0";
           }
           else
           {
               st = "1";
           }
           con.Close();

           return st;

           
        }
         [WebMethod]
        public DataSet  grid()
        {
           // string st;
            SqlConnection con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=TRIESTEN-PC");
            con.Open();
            SqlCommand cmd = new SqlCommand("sp_register1", con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter ad = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            ad.Fill(ds);
           
            con.Close();

            return ds;


        }
    }
}

Webform.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="webservices.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtuser" runat="server" ></asp:TextBox>
        <asp:TextBox ID="txtpass" runat="server" ></asp:TextBox>
        <asp:Button ID="bt" runat="server" Text="Save" OnClick="bt_Click" />
   
    </div>
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
    </form>
</body>
</html>


Webform.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;


namespace webservices
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        localhost.sample lo = new localhost.sample();
       
        protected void Page_Load(object sender, EventArgs e)
        {
            data();
        }

        protected void bt_Click(object sender, EventArgs e)
        {
           string st= lo.insert(txtuser.Text, txtpass.Text);
           if (st == "0")
           {
               Response.Write("insert sucess");
           }
        }
        public void data()
        {
            DataSet ds = new DataSet();
            ds = lo.grid();
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
    }
}