Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Nevron Gauge for SharePoint
Search :       Advanced Search »
Home » ASP.NET 2.0/3.5 » On-line Address Book in ASP.NET 2.0

On-line Address Book in ASP.NET 2.0

This is a small project on On Line Address Book. This small project will be very useful for those who are going to start or new in ASP.NET.

Author Rank :
Page Views : 29463
Downloads : 1525
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
OnLineAddressBook.zip
 
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

This is an on-line address book project. Learn with this small project how to develop an application using .net 2.0. Those who are new to ASP.NET or going for first project can learn a lot from this. This is a project to keep the address and other information. In our daily life we meet many people and we have to keep the information and addresses of these people. This project is very useful to keep the record.

To use this project just change the connection string.

Welcome.aspx

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

<!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>Welcome</title>

</head>

<body>

  <form id="form1" runat="server">

    <div>

      <table cellpadding="0" cellspacing="0" width="100%"   

                background="BackGround.jpg">

        <tr><td align="center">

              <asp:Label ID="lblWelcome" runat="server"
                       Text="Welcome In On Line Address Book"

                     Font-Bold="true"  Font-Size="22pt"  ForeColor="#6600ff"> </asp:Label>

            </td></tr>

            <tr><td>&nbsp;</td></tr>

            <tr><td align="center">

                  <asp:Label ID="lblDoAddress" runat="server"
                                     Text="Do Your Address On Line" Font-Bold="true"

                         ForeColor="#33cccc"  Font-Size="14pt"></asp:Label>

                 </td></tr>

            <tr><td height="50px">&nbsp;</td></tr>

            <tr><td align="center">

                  <asp:ImageButton ID="Imgm" ImageUrl="~/case2-a.gif" runat="server" OnClick="StartAddress" />

                </td></tr>

            <tr><td>&nbsp;</td></tr>

            <tr><td align="center">

                  <asp:Label ID="lblAddress" runat="server" Text="(Address Book)" Font-Bold="true" ForeColor="#000099"
                            Font-Size="16pt"></asp:Label>

                </td></tr>

            <tr><td height="190px"></td></tr>

            <tr><td>&nbsp;&nbsp; &nbsp;&nbsp; <asp:Button ID="btnAddressBook" runat="server" 
                            Text="Go Inside The Address Book" BackColor="#ff9900" Height="45px" OnClick="btnInside_Click" />

            </td></tr>

          

      </table>

      <table background="BackGround.jpg" cellpadding="0" cellspacing="0" width="100%">

        <tr><td align="right">

              <asp:Label ID="lblName" runat="server" Text="Rahul Saxena" Font-Bold="true" Font-Size="16pt"

                 ForeColor="#6600ff"></asp:Label><br /><br />

              <asp:Label ID="lblEmail" runat="server" Text="Email: 14rahulsaxena@gmail.com" Font-Bold="true" 

                           Font-Size="14pt"   ForeColor="#6600ff"></asp:Label>

            </td><td width="5%"></td></tr>

        <tr><td Height="43px"></td></tr>

      </table>   

    </div>

  </form>

</body>

</html>

The  window will be:



Figure 1: Welcome window.

Welcome.aspx.cs is:

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

 

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

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

    protected void btnInside_Click(object sender, EventArgs e)

    {

        Response.Redirect("AllRecord.aspx");

    }

    protected void StartAddress(object sender, ImageClickEventArgs e)

    {

        Response.Redirect("AllRecord.aspx");

    }

}

AllRecord.aspx

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

<!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>All Record</title>

</head>

<body>

  <form id="form1" runat="server">

    <div>

      <table cellpadding="0" cellspacing="0" width="90%" border="0" height="100%">

        <tr><td width="10px"></td><td><asp:Image ID="imageContact" runat="server"  ImageUrl="~/clip1-c.gif"/>
         </
td></tr>

        <tr><td width="10px"></td><td width="90%"  background="BackGround.jpg" align="left">
                 
&nbsp; &nbsp; &nbsp;&nbsp;

              <asp:Button ID="btnSubmit" runat="server" Text="Add New Address" OnClick="btnSubmit_Click" />
                         
&nbsp; &nbsp; &nbsp; &nbsp;
              
<asp:Button ID="btnSearch"  runat="server" Text="Search A Address"  OnClick="SearchRecord" />
                           
&nbsp; &nbsp;
&nbsp;&nbsp; &nbsp; &nbsp;

              <asp:Image ID="ImgMove" runat="server" ImageUrl="~/ball1-a.gif" />

              <asp:Label ID="lblSearch" Text="All Address" runat="server" Font-Bold="true"  ForeColor="#ff6600"
                        
 Font-Size="16pt"> </asp:Label>

                 &nbsp; &nbsp; &nbsp; &nbsp;

             <asp:Image ID="ImgDate" runat="server" ImageUrl="~/hourglass-b.gif" />

             <asp:Label ID="lblShowTime" runat="server" Text="Date" Font-Bold="true"> </asp:Label>
                   
&nbsp; &nbsp;

             <asp:Label ID="lbltime" runat="server"></asp:Label>

           </td></tr>

        <tr><td height="5px"></td></tr>

        <tr><td width="10px"></td>

             <td><table background="BackGround.jpg"  cellpadding="0" cellspacing="0" height="100%"
                   
 border="0" width="100%">

                   <tr><td height="25px"></td></tr>

                   <tr><td width="10px"></td><td align="center" >

                         <asp:DataGrid ID="GridAllRecord" runat="server"  AutoGenerateColumns="false" Width="90%" 
                            DataKeyField="ID" 
PagerStyle-HorizontalAlign ="Center"  BorderStyle="ridge" GridLines="Both"

                                BorderWidth="2px" BorderColor ="white" BackColor="white" CellPadding="3" CellSpacing="1"

                                OnEditCommand="EditAddress"  OnDeleteCommand="AddressDelete"

                                OnItemCommand="Grid_ItemCommand" AllowSorting="true" PageSize=5

                                OnPageIndexChanged="GridAllRecord_PageIndexChanged" AllowPaging="true">

                         <FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>

                         <HeaderStyle Font-Bold="True" ForeColor="#FFFFFF" BackColor="#A53A6A"></HeaderStyle>

                         <FooterStyle BackColor="beige" />

                         <PagerStyle Font-Bold="true" Mode=NumericPages Font-Underline="true"/>

                         <Columns>

                           <asp:BoundColumn DataField=ID HeaderText="ID" Visible="false">

                             <ItemStyle BackColor="graytext" />

                             <HeaderStyle BackColor="graytext" />

                           </asp:BoundColumn>

                       

                           <asp:TemplateColumn HeaderText="First Name">

                             <ItemTemplate>

                               <asp:LinkButton ID="lnkName" runat="server"  Text='<%#DataBinder.Eval

                                   (Container.DataItem,"FirstName") %>' CommandName="RecordShow"> </asp:LinkButton>

                             </ItemTemplate>

                           </asp:TemplateColumn>           

                          

                           <asp:BoundColumn DataField=LastName HeaderText="Last Name">

                             <ItemStyle BackColor=GhostWhite />

                           </asp:BoundColumn>               

                          

                           <asp:BoundColumn DataField=PersonelEmail HeaderText="Personnel(EMail)">

                             <ItemStyle BackColor=GhostWhite />

                           </asp:BoundColumn>         

                          

                           <asp:BoundColumn DataField=Mobile HeaderText="Mobile">

                             <ItemStyle BackColor=GhostWhite />

                           </asp:BoundColumn>   

                             

                           <asp:EditCommandColumn EditText="Edit Address" HeaderText="Edit Address">

                 </asp:EditCommandColumn>      

                           <asp:ButtonColumn  CommandName="DeleteAddress" HeaderText="Delete Address"

                                  Text="Delete"></asp:ButtonColumn>

                         </Columns>   

                      </asp:DataGrid>

                    </td>

                  </tr>

                <tr><td height="25px"></td></tr>

              </table></td></tr>

           <tr><td height="15px"></td></tr>

         <%-- <tr><td width="10px"></td><td><asp:Label ID="lblTotalRegisterartion" runat="server"
                   Text="Total Registered Address :"></asp:Label><asp:Label ID="lblRegistered"    

                                                 runat="server"></asp:Label></td></tr>--%>

       </table>   

     </div>

    </form>

  </body>

</html>

AllRecord.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

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

{

    string connect = @"Data Source=MCN0100;Initial Catalog=AddressBook; Uid=sa; Pwd=";

    SqlConnection con;

    SqlCommand cmd = new SqlCommand();

    SqlDataAdapter da;

    DataSet ds = new DataSet();

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            rebind();

            string Time = DateTime.Now.Date.ToShortDateString();

            lbltime.Text = Time;

            //TotalUsers();

        }

    }

 

    public void rebind()

    {

        con = new SqlConnection(connect);

        cmd.CommandText = "select ID,FirstName,LastName, Mobile, PersonelEmail from record";

        da = new SqlDataAdapter(cmd);

        cmd.Connection = con;

        da.Fill(ds);

        con.Open();

        cmd.ExecuteNonQuery();

        GridAllRecord.DataSource = ds;

        GridAllRecord.DataBind();

    }

    protected void btnSubmit_Click(object sender, EventArgs e)

    {

        Response.Redirect("Register.aspx");

    }

 

    protected void Grid_ItemCommand(object sender, DataGridCommandEventArgs e)

    {

        if (e.CommandName == "RecordShow")

        {

            int Rep_Id = int.Parse(e.Item.Cells[0].Text);

            Session["ID"] = Rep_Id;

            Response.Redirect("ShowSelectedRecord.aspx");

        }

        if (e.CommandName == "DeleteAddress")

        {

            con = new SqlConnection(connect);

            int UpadteAddress = int.Parse(e.Item.Cells[0].Text);

            cmd.CommandText = "delete from Record where ID=" + UpadteAddress;

            cmd.Connection = con;

            con.Open();

            cmd.ExecuteNonQuery();

            con.Close();          

            GridAllRecord.EditItemIndex=-1;

            rebind();                   

        }

    }

 

    protected void SearchRecord(object sender, EventArgs e)

    {

        Response.Redirect("Search.aspx");

    }

 

    public void GridAllRecord_PageIndexChanged(object source, DataGridPageChangedEventArgs e)

    {

        GridAllRecord.CurrentPageIndex = e.NewPageIndex;

        rebind();

    }

 

    public void EditAddress(object ssender, DataGridCommandEventArgs e)

    {

        int UpadteAddress = int.Parse(e.Item.Cells[0].Text);

        Session["UpadteAddressID"] = UpadteAddress;

        Response.Redirect("LoginCheck.aspx");

    }

 

    public void AddressDelete(object sender, DataGridCommandEventArgs e)

    {

        con = new SqlConnection(connect);

        int UpadteAddress = int.Parse(e.Item.Cells[0].Text);

        cmd.CommandText = "delete from Record where ID=" + UpadteAddress;

        cmd.Connection = con;

        con.Open();

        cmd.ExecuteNonQuery();

        con.Close();      

        GridAllRecord.EditItemIndex=-1;

        rebind();

    } 

 

    //public void TotalUsers()

    //{

    //    con = new SqlConnection(connect);

    //    cmd.CommandText = "select  *  from Record";

    //    da = new SqlDataAdapter(cmd);

    //    da.Fill(ds);

    //    cmd.Connection = con;

    //    con.Open();

    //    cmd.ExecuteNonQuery();

    //    int TotalUser = int.Parse(ds.Tables[0].Rows.Count.ToString());

    //    lblRegistered.Text = TotalUser.ToString();

    //    con.Close();

    //}

}

The output of the application:



Figure 2: All Record.


Register.aspx

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Register.aspx.cs" Inherits="_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>Address Book</title>

</head>

<body>

  <form id="form1" runat="server">

    <div>

      <table cellpadding="0" cellspacing="0" width="90%" border="0" align=center>

        <tr><td>

          <table cellpadding="0" cellspacing="0" width="80%" align="center" border="4" background=BackGround.jpg>

            <tr><td align="center"><asp:Label ID="lblWelcome" Text="Welcome On Line Address Book" runat="server"
                  
 Font-Bold="true" Font-Size="14pt" ForeColor="black"> </asp:Label>

                 </td></tr>  

             <tr><td><marquee bgcolor="#ff9900" behavior="alternate">

                   <asp:Label ID="lblInformationfill" runat="server" Text="Please Fill The Information" ForeColor="#0000ff"
                   
 Font-Bold="true"> </asp:Label> </marquee>

                 </td></tr>

             <tr><td><asp:Label ID="lblRecordAdded" runat="server" Visible="false" ForeColor="Red">
                           </
asp:Label> </td> </tr>

              <tr><td>
              
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;    

                &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

                          <asp:Label ID="lbltitle" runat="server" Text="Select Title" Width="100" Font-Bold="true">

                            </asp:Label>

                   <asp:DropDownList ID="listTitle" runat="server">

                     <asp:ListItem Value="Select">--Select--</asp:ListItem>

                     <asp:ListItem Value="Mr">Mr</asp:ListItem>

                     <asp:ListItem Value="Ms">Ms</asp:ListItem>

                   </asp:DropDownList>
               
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp

  </td></tr>             

               <tr><td align="center" style="height: 233px">

                    <table cellpadding="0" cellspacing="0" width="80%" border="0">

                      <tr><td align="center">

                        <table>                         

                          <tr><td><marquee> <asp:Label ID="lblPersonnelInformation" runat="server" 
                                                            
Text="Personnel Information" 
Font-Bold="True" ForeColor=ActiveCaption>

                                 </asp:Label> </marquee>

                                </td></tr>

                          <tr><td align="left"><asp:Label ID="lblFirstNmae" Text="First Name" runat="server" Width="100px"

                                                                ForeColor=ActiveCaption> </asp:Label>

                                                      <asp:TextBox ID="txtFirstName" runat="server"> </asp:TextBox>

                               </td></tr>

                            <tr><td align="left"><asp:Label ID="lblMiddleName" Text="Middle Name" runat="server" Width="100px"

                                                   ForeColor=ActiveCaption> </asp:Label>

                                                      <asp:TextBox ID="txtMiddleName" runat="server"></asp:TextBox>

                                </td></tr>

                            <tr><td align="left"> <asp:Label ID="lblLastName" Text="Last Name" runat="server" Width="100px"

                                                               ForeColor=ActiveCaption> </asp:Label>

                                                 <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>

                                 </td></tr>

                            <tr><td align="left"> <asp:Label ID="lblHomePhone" Text="Home Phone" runat="server"
                                                       
Width="100px" 
ForeColor=ActiveCaption> </asp:Label>

                                    <asp:TextBox ID="txtHomePhone" runat="server"></asp:TextBox>

                            </td></tr>

                            <tr><td align="left"><asp:Label ID="lblMobile" Text="Mobile" runat="server" Width="100px"

                                   ForeColor=ActiveCaption> </asp:Label>

                                                <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>

                                 </td></tr>                           

                            <tr><td align="left"><asp:Label ID="lblPersonelEmail" Text="Email" runat="server" Width="100px"

                                           ForeColor=ActiveCaption>  </asp:Label>

                                                <asp:TextBox ID="txtPersonnelEmail" runat="server"></asp:TextBox>

                            </td></tr>

                         </table></td>

                         <td>

                           <table>

                              <tr><td><marquee><asp:Label ID="lblOfficeInformation" runat="server" Text="Official Information" 
                                      
Font-Bold="True" ForeColor="Chocolate"> </asp:Label> </marquee> </td> </tr>

                              <tr><td align="left"><asp:Label ID="lblCompany" Text="Company" runat="server" Width="100px"

                                          ForeColor="Chocolate"> </asp:Label>

                                   <asp:TextBox ID="txtCompany" runat="server"></asp:TextBox>

                                   </td></tr>

                           

                               <tr><td align="left"><asp:Label ID="lblJobTitle" Text="Job Title" runat="server" Width="100px"

                                                                         ForeColor="Chocolate"> </asp:Label>

                                                    <asp:TextBox ID="txtJobTitle" runat="server"></asp:TextBox>

                                    </td></tr>

                               <tr><td align="left"><asp:Label ID="lblWebSite" Text="Web Site" runat="server" Width="100px"

                                                                       ForeColor="Chocolate"></asp:Label>

                                                    <asp:TextBox ID="txtWebSite" runat="server"></asp:TextBox>

                                     </td></tr>

                               <tr><td align="left"><asp:Label ID="lblOfficePhone" Text="OfficePhone" runat="server" 
                                            
Width="100px" 
  Color="Chocolate"> </asp:Label>

                                                    <asp:TextBox ID="txtOfficePhone" runat="server"></asp:TextBox>

                                    </td></tr>                           

                               <tr><td align="left"><asp:Label ID="lblFax" Text="Fax" runat="server" Width="100px"

                                                                           ForeColor="Chocolate"> </asp:Label>

                                                    <asp:TextBox ID="txtFax" runat="server"></asp:TextBox>

                              </td></tr>

                           

                              <tr><td align="left"><asp:Label ID="lblOfficeEmail" Text="Office Email"  runat="server" ></asp:Label>

                          <asp:TextBox ID="txtOfficeEmail" runat="server"></asp:TextBox>

                                      </td></tr> 

                        </table></td>

                       </tr>

                    </table></td></tr>

                       

                  <tr><td>
                    
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                      
<asp:Label ID="lblAddress" runat="server" Text="Address" ForeColor=ActiveCaption> </asp:Label>

                             &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                       
<asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine"> </asp:TextBox>
                    </
td></tr>     

                  <tr><td align="center" style="height: 52px">
                        <
asp:Button ID="btnSubmitRecord" runat="server" Text="Submit" Height="40px"
                                
OnClick="btnSubmit_Click" Width="200px"/>

                       &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

                       <asp:ImageButton ID="ImageMain" runat="server" ImageUrl="~/5ar04a.gif" OnClick="Main_Click" 
                               
ToolTip="Click Here To Go On All Record"/>

             </td></tr>

           </table>

        </td></tr>

      </table>

     </div>

    </form>

</body>

</html>  


Register.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

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

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

 

    SqlConnection con;

    SqlCommand cmd = new SqlCommand();

    string connection = @"Data Source=MCN0100;Initial Catalog=AddressBook; Uid=sa; Pwd=";   

 

    protected void btnSubmit_Click(object sender, EventArgs e)

    {

        if (txtFirstName.Text !="" && txtLastName.Text !="")

        {

            InserRecord();

            txtFirstName.Text = "";

            txtLastName.Text = "";

            txtMiddleName.Text = "";

            txtJobTitle.Text = "";

            txtCompany.Text = "";

            txtWebSite.Text = "";

            txtOfficePhone.Text = "";

            txtHomePhone.Text = "";

            txtMobile.Text = "";

            txtFax.Text = "";

            txtOfficeEmail.Text = "";

            txtPersonnelEmail.Text = "";      

            txtAddress.Text="";   

        }

        else

        {

            lblRecordAdded.Visible = true;

            lblRecordAdded.Text = "Please Fill First Name and Last Name ";           

        }

    }

 

    public void InserRecord()

    {       

        con = new SqlConnection(connection);

        cmd.CommandText = "insert into Record( Title,FirstName, LastName,MiddleName, JobType,Company, WebSite,

 OfficePhone, HomePhone, Mobile,Fax, OfficialEmail, PersonelEmail,Address)  values('" + listTitle.Text + "','" + txtFirstName.Text + "',

'" + txtLastName.Text + "','" +  txtMiddleName.Text + "','" +  txtJobTitle.Text + "',

'" + txtCompany.Text +  "','" +  txtWebSite.Text + "',

'" +  txtOfficePhone.Text + "','" + txtHomePhone.Text + "','" + txtMobile.Text + "','" + txtFax.Text + "','" + txtOfficeEmail.Text + "',

'" + txtPersonnelEmail.Text +  "','"+ txtAddress.Text + "')";

        cmd.Connection = con;

        con.Open();

        cmd.ExecuteNonQuery();

        con.Close();

        lblRecordAdded.Visible = true;

        lblRecordAdded.Text = "Your Address has benn sucessfuly Submitted, Thanx for add a Record ";       

    }

    protected void Main_Click(object sender, ImageClickEventArgs e)

    {

        Response.Redirect("Allrecord.aspx");

    }

}

Adding a new Record



Figure 3: Add a new address.

Search.aspx

 

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

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 T ransitional//EN" "http://www.w3.org/

TR/xhtml1/DTD/xhtml1- transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Search</title>

 

</head>

<body>

  <form id="form1" runat="server">

    <div>

      <table cellpadding="0" cellspacing="0" width="70%" border="4" background="BackGround.jpg" align="center">

        <tr><td><marquee>

                  <asp:Label ID="lblsearchName" runat="server" Text="Search Your Address"

                            BackColor="#ff9900"></asp:Label>

                  </marquee>

              </td></tr>

        <tr><td>&nbsp;&nbsp;
           
<asp:Label ID="lblSearch" runat="server" Text="Search By:" Font-Bold="true"

                    ForeColor="#0000ff">  </asp:Label>

                  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;

                <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>   

          </td></tr>

        <tr><td height="5px"></td></tr>

        <tr><td>&nbsp;&nbsp; &nbsp; &nbsp;
                    
<asp:Label ID="lblIDsearch" runat="server" Text="ID" Width="120px"> </asp:Label>

                          &nbsp;&nbsp;

                    <asp:TextBox ID="txtIDSearch" runat="server"></asp:TextBox
                    &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;

                  &nbsp;&nbsp;

                          <asp:Button ID="btnIDSearch" runat="server" Text="Search" OnClick="btnIDSearch_Click" />

          </td></tr>

        <tr><td height="5px"></td></tr>

        <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;
                 
<asp:Label ID="lblName" runat="server" Text="First Name" Width="120px"></asp:Label>

                  &nbsp;&nbsp;

                 <asp:TextBox ID="txtFirstNameSearch" runat="server"> </asp:TextBox> 

      &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;

                 <asp:Button ID="btnNameSearch" runat="server" Text="Search" OnClick="btnFirstNameSearch_click" />

            </td></tr>

        <tr><td height="5px"></td></tr>

        <tr><td>&nbsp;&nbsp; &nbsp;&nbsp;
                 
<asp:Label ID="lblLastName" runat="server" Text="Last Name"  Width="120px"> </asp:Label>

                &nbsp;&nbsp;

                <asp:TextBox ID="txtLastNameSearch" runat="server"></asp:TextBox>
                     
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp; &nbsp; &nbsp;

                             &nbsp;&nbsp;&nbsp;

                <asp:Button ID="btnLastNameSearch" runat="server" Text="Search" OnClick="btnLastNameSearch_Click" />

        </td></tr>

   

        <tr><td height="5px"></td></tr>

        <tr><td>&nbsp;&nbsp; &nbsp;&nbsp;
               
<asp:Label ID="lblMobilesearch" runat="server" Text="
Mobile"  Width="120px"> </asp:Label>

                &nbsp;&nbsp;

                <asp:TextBox ID="txtMobileSearch" runat="server"></asp:TextBox>
                  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                <asp:Button ID="btnMobileSearch" runat="server" Text="Search" OnClick="btnMobileSearch_Click" />

            </td></tr>

       

            <tr><td height="5px"></td></tr>

            <tr><td>&nbsp; &nbsp;&nbsp; &nbsp;
                    
<asp:Label ID="lblEmailSearch" runat="server" Text="Email"  Width="120px"></asp:Label> &nbsp; &nbsp;

                     <asp:TextBox ID="txtEmailSearch" runat="server"> </asp:TextBox>

             &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;

                &nbsp;&nbsp;

                       <asp:Button ID="btnEmailSearch" runat="server" Text="Search" OnClick="btnEmailSearch_Click" />

         </td></tr>

        <tr><td> <asp:ImageButton ID="ImageMain" runat="server" ImageUrl="~/5ar04a.gif" OnClick="Main_Click" 
                     
ToolTip="Click Here To Go On All Record"/></td></tr>  

      </table>

      <table cellpadding="0" cellspacing="0" border="0" width="70%" align="center">

        <tr><td height="5px"></td></tr>

        <tr><td>

              <asp:DataGrid ID="GridAllRecord" runat="server" AutoGenerateColumns="false"
                  Width
="100%" DataKeyField="ID"

                    BorderStyle="ridge"  GridLines="Both" BorderWidth="2px" BorderColor ="white"  BackColor="white"
                    CellPadding="0" 
CellSpacing="0"  OnItemCommand="Grid_ItemCommand" AllowSorting="true"   

                          PagerStyle-HorizontalAlign="Center" PageSize=5 AllowPaging="true">

              <FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>

              <HeaderStyle Font-Bold="True" ForeColor="#FFFFFF" BackColor="#A53A6A"></HeaderStyle>

              <FooterStyle BackColor="beige" />

              <PagerStyle Font-Bold="true" Mode=NumericPages Font-Underline="true"/>

              <Columns>

                <asp:BoundColumn DataField=ID HeaderText="ID" Visible="false">

                  <ItemStyle BackColor="graytext" />

                  <HeaderStyle BackColor="graytext" />

                </asp:BoundColumn>

                <asp:TemplateColumn HeaderText="First Name" >

                  <ItemTemplate>

                    <asp:LinkButton ID="lnkName" runat="server"
                      Text='<%#DataBinder.Eval(Container.DataItem,"FirstName") %>' CommandName="RecordShow">

                           </asp:LinkButton>

                  </ItemTemplate>

                </asp:TemplateColumn>           

                <asp:BoundColumn DataField=OfficialEmail HeaderText="Official(EMail)">

                  <ItemStyle BackColor=GhostWhite />

                    </asp:BoundColumn>               

                <asp:BoundColumn DataField=PersonelEmail HeaderText="Personnel(EMail)">

                  <ItemStyle BackColor=GhostWhite />

                </asp:BoundColumn>         

                <asp:BoundColumn DataField=Mobile HeaderText="Mobile">

              <ItemStyle BackColor=GhostWhite />

            </asp:BoundColumn>                               

          </Columns>   

      </asp:DataGrid>

    </td></tr></table>

  </div>

 </form>

</body>

</html>

 

Search.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

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

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

    SqlConnection con;

    SqlDataAdapter da;

    SqlCommand cmd = new SqlCommand();

    DataSet ds = new DataSet();

    string connect = @"Data Source=MCN0100;Initial Catalog=AddressBook; Uid=sa; Pwd=";

    string commandSearch;

 

    protected void btnFirstNameSearch_click(object sender, EventArgs e)

    {

        if (txtFirstNameSearch.Text == "")

        {

            lblError.Text = "Please Enter First Name";

        }

        else

        {

            commandSearch = "select * from Record where FirstName='" + txtFirstNameSearch.Text + "'";

            showSearchRecord();

        }

    }

 

    protected void btnLastNameSearch_Click(object sender, EventArgs e)

    {

        if (txtLastNameSearch.Text == "")

        {

            lblError.Text = "Please Enter Last Name";

        }

        else

        {

            commandSearch = "select * from Record where LastName='" + txtLastNameSearch.Text + "'";

            showSearchRecord();

        }

    }

 

    protected void btnMobileSearch_Click(object sender, EventArgs e)

    {

        if (txtMobileSearch.Text == "")

        {

            lblError.Text = "Please Enter a Mobile Number";

        }

        else

        {

            commandSearch = "select * from Record where Mobile='" + txtMobileSearch.Text + "'";

            showSearchRecord();

        }

    }

 

    protected void btnEmailSearch_Click(object sender, EventArgs e)

    {

        if (txtEmailSearch.Text == "")

        {

            lblError.Text = "Please Enter a Email";

        }

        else

        {

            commandSearch = "select * from Record where personelEmail='" + txtEmailSearch.Text + "'";

            showSearchRecord();

        }

    }

 

    public void showSearchRecord()

    {

        con = new SqlConnection(connect);

        cmd.CommandText = commandSearch;

        cmd.Connection = con;

        da = new SqlDataAdapter(cmd);

        da.Fill(ds);

        con.Open();

        cmd.ExecuteNonQuery();

        if (ds.Tables[0].Rows.Count > 0)

        {

            lblError.Text = "";

            GridAllRecord.DataSource = ds;

            GridAllRecord.DataBind();

        }

        else

        {

            lblError.Text = "No Address Found  For This Search";

            GridAllRecord.DataSource = null;

            GridAllRecord.DataBind();

        }

    }

 

    protected void Grid_ItemCommand(object sender, DataGridCommandEventArgs e)

    {

        if (e.CommandName == "RecordShow")

        {

            int  Id = int.Parse(e.Item.Cells[0].Text);

            Session["ID"] =  Id;

            Response.Redirect("ShowSelectedRecord.aspx");

        }

    }

    protected void btnIDSearch_Click(object sender, EventArgs e)

    {

        if (txtIDSearch.Text == "")

        {

            lblError.Text = "Please Enter a ID";

        }

        else

        {

            commandSearch = "select * from Record where ID='" + txtIDSearch.Text + "'";

            showSearchRecord();

        }

    }

    protected void Main_Click(object sender, ImageClickEventArgs e)

    {

        Response.Redirect("Allrecord.aspx");

    }

}



Figure 4: Searching a address.

Login.aspx

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

<!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>Login User</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <table cellpadding="0" cellspacing="0" width="60%" align="center" border=4 background="BackGround.jpg">    

    <tr><td align="center"><asp:Label ID="lblLoginWelcome" runat="server"
       
 Text="Wecome Here In OnLine Address Book" ForeColor="Blue" Font-Bold="true"></asp:Label> </td></tr>

    <tr><td><asp:Label ID="lblError" runat="server" Visible=false ForeColor="blue"></asp:Label></td></tr>

    <tr><td><table cellpadding="0" cellspacing="0" width="50%" align="center" border="0">

    <tr><td height="15px"></td></tr>

    <tr><td><asp:Label ID="lblLogin" runat="server" Text="Login" Width="112px" Font-Bold="true"

                             ForeColor="#990066"></asp:Label>
                  <
asp:TextBox ID="txtLogin" runat="server"> </asp:TextBox> </td></tr>

    <tr><td height="15px"></td></tr>

    <tr><td><asp:Label ID="lblPassword" runat="server" Text="Password" Width="112px" Font-Bold="true"

                         ForeColor="#990066"></asp:Label>
                <
asp:TextBox ID="txtPassword" runat="server" TextMode="Password"> </asp:TextBox> </td> </tr>

     <tr><td height="15px"></td></tr>

     <tr><td align="center"><asp:Button ID="btnLogin" runat="server" OnClick="btnLogin_Click"
                   
 Text="Login" Width="76px" /> </td> </tr>

    </table></td></tr>

    </table>

   

    </div>

    </form>

</body>

</html>  

 

Login.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

 

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

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

    protected void btnLogin_Click(object sender, EventArgs e)

    {

        if (txtLogin.Text == "rahul" && txtPassword.Text == "saxena")

        {

            Response.Redirect("UpdateTheRecord.aspx");

        }

        else

        {

            lblError.Visible = true;

            lblError.Text = "Invalid User";

        }

    }

}



Figure 5: If user want to update the address then he have to Login before edit the an address

UpdateRecord

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

<!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 id="Head1" runat="server">

    <title>Update Record</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

     <table cellpadding="0" cellspacing="0" border="1" width="90%" align="center"

                    background="BackGround.jpg">

       <tr><td align="center"><table cellpadding="0" cellspacing="0" width="80%"

                      border="0" align="center">

       <tr><td align="center" style="border-bottom:2px solid;">

              <asp:Label ID="lblName" runat="server"

                  Text="Update Personnel Information" Font-Bold="true"  Font-   

                           Size="14pt" ForeColor="#0099ff"> </asp:Label>

            </td>

            <td align="center" style="border-bottom:2px solid;">

               <asp:Label ID="Label1" runat="server"

                      Text="Update Professional Information"  Font-Bold="true" Font-

                              Size="14pt" ForeColor="#ff6600"> </asp:Label>

            </td>

       </tr>                

       <tr><td align="center">

             <table>                 

               <tr><td><marquee>

                         <asp:Label ID="lblPersonnelInformation" runat="server"

                                 Text="Personnel Information"  Font-Bold="True" 

                                    ForeColor=ActiveCaption></asp:Label>

                       </marquee>

                    </td>

               </tr>

              <tr><td align="left">

                    <asp:Label ID="lblFirstNmae" Text="First Name" runat="server"            

                        Width="100px"  ForeColor=ActiveCaption>

                     </asp:Label>

                    <asp:TextBox ID="txtFirstName" runat="server"

                        Enabled=false> </asp:TextBox>

                   </td>

              </tr>

             <tr><td align="left">

                   <asp:Label ID="lblMiddleName" Text="Middle Name" runat="server"

                           Width="100px" ForeColor=ActiveCaption>

                    </asp:Label>

                    <asp:TextBox ID="txtMiddleName" runat="server"

                            Enabled=false></asp:TextBox>

                  </td>

             </tr>

              <tr><td align="left">

                    <asp:Label ID="lblLastName" Text="Last Name" runat="server"

                       Width="100px" ForeColor=ActiveCaption>

                    </asp:Label>

                     <asp:TextBox ID="txtLastName" runat="server" Enabled=false>

                    </asp:TextBox>

                   </td>

              </tr>

              <tr><td align="left">

                    <asp:Label ID="lblHomePhone" Text="Home Phone" runat="server"

                                Width="100px" ForeColor=ActiveCaption>

                    </asp:Label>

                    <asp:TextBox ID="txtHomePhone" runat="server">

                    </asp:TextBox>

                   </td>

               </tr>                                                                  

               <tr><td align="left">

                     <asp:Label ID="lblMobile" Text="Mobile" runat="server"

                                 Width="100px" ForeColor=ActiveCaption>

                     </asp:Label>

                     <asp:TextBox ID="txtMobile" runat="server">

                     </asp:TextBox>

                   </td>

                </tr>                          

                <tr><td align="left">

                      <asp:Label ID="lblPersonelEmail" Text="Email" runat="server"

                                 Width="100px" ForeColor=ActiveCaption>

                      </asp:Label>

                      <asp:TextBox ID="txtPersonnelEmail" runat="server">

                      </asp:TextBox>

                    </td>

                </tr>

              </table></td>                    

             <td>

                 <table>

                      <tr><td><marquee>

                                <asp:Label ID="lblOfficeInformation" runat="server"

                                       Text="Official Information" Font-Bold="True"

                                                 ForeColor="Chocolate">

                                </asp:Label>

                              </marquee>

                           </td>

                       </tr>

                       <tr> <td align="left">

                              <asp:Label ID="lblCompany" Text="Company" runat="server"

                                              Width="100px" ForeColor="Chocolate">

                              </asp:Label>

                              <asp:TextBox ID="txtCompany" runat="server">

                              </asp:TextBox>

                            </td>

                       </tr>                      

                       <tr><td align="left">

                             <asp:Label ID="lblJobTitle" Text="Job Title" runat="server"

                                              Width="100px" ForeColor="Chocolate">

                             </asp:Label>

                             <asp:TextBox ID="txtJobTitle" runat="server">

                             </asp:TextBox>

                           </td>

                         </tr>

                        <tr><td align="left">

                              <asp:Label ID="lblWebSite" Text="Web Site" runat="server"

                                               Width="100px" ForeColor="Chocolate">

                              </asp:Label>

                              <asp:TextBox ID="txtWebSite" runat="server">

                              </asp:TextBox>

                            </td>

                        </tr>                          

                        <tr><td align="left">

                              <asp:Label ID="lblOfficePhone" Text="OfficePhone"

                                         runat="server" Width="100px"  ForeColor="Chocolate">

                              </asp:Label>

                              <asp:TextBox ID="txtOfficePhone" runat="server">

                              </asp:TextBox>

                            </td>

                        </tr>

                        <tr><td align="left">

                              <asp:Label ID="lblFax" Text="Fax" runat="server"

                                       Width="100px" ForeColor="Chocolate">

                              </asp:Label>

                              <asp:TextBox ID="txtFax" runat="server"> </asp:TextBox>

                            </td>

                         </tr>

                         <tr><td align="left">

                               <asp:Label ID="lblOfficeEmail" Text="Office Email"

                                          runat="server" Width="100px" ForeColor="Chocolate">

                               </asp:Label>

                               <asp:TextBox ID="txtOfficeEmail" runat="server">

                               </asp:TextBox><td></tr>

                     </table></td>

                  </tr>

                  <tr><td>

                       <asp:Label ID="Label2" runat="server" Width="120px"

                                Text="Address" Font-Bold="true" ForeColor=ActiveCaption>

                       </asp:Label>

                       <asp:TextBox ID="txtAddress" runat="server"

                                        TextMode="MultiLine">

                       </asp:TextBox>

                     </td>

                 </tr>

             </table></td></tr>    

             <tr><td height="5px"></td></tr>

            <tr><td align="center" height="50px">

                <asp:Button ID="btnUpdateRecord" runat="server" Text="Update The

                             Record" Width="303px" OnClick="UpdateRecord_Click" />

                 &nbsp;&nbsp; &nbsp; &nbsp;

                <asp:ImageButton ID="ImageMain" runat="server"

                                 ImageUrl="~/5ar04a.gif" OnClick="Main_Click" 

                                    ToolTip="Click Here To Go On All Record"/>

            </td></tr>

        </table>    

      </div>

    </form>

  </body>

</html> 

UpdateRecord.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

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

{

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            record4Update();

        }

    }

    SqlConnection con;

    SqlDataAdapter da;

    SqlCommand cmd = new SqlCommand();

    DataSet ds = new DataSet();

    string connect = @"Data Source=MCN0100;Initial Catalog=AddressBook; Uid=sa; Pwd=";

 

    protected void UpdateRecord_Click(object sender, EventArgs e)

    {

        int IDUpdate = int.Parse(Session["UpadteAddressID"].ToString());

        con = new SqlConnection(connect);

        cmd.CommandText = "update Record set Jobtype='" + txtJobTitle.Text + "' ,

Company='" +  txtCompany.Text +  "', WebSite='" +  txtWebSite.Text + "',  OfficePhone='" + txtOfficePhone.Text + "', 

HomePhone='" +  txtHomePhone.Text  + "',Mobile='" + txtMobile.Text + "', Fax='" + txtFax.Text  + "',

OfficialEmail='" + txtOfficeEmail.Text + "', PersonelEmail='" +  txtPersonnelEmail.Text + "', Address='"+txtAddress.Text+"' where ID="+IDUpdate;;

        cmd.Connection = con;

        con.Open();

        cmd.ExecuteNonQuery();

        con.Close();

    }

 

    public void record4Update()

    {

        int IDUpdate = int.Parse(Session["UpadteAddressID"].ToString());

        con = new SqlConnection(connect);

        cmd.CommandText = "select * from Record where ID=" + IDUpdate;

        cmd.Connection = con;

        da = new SqlDataAdapter(cmd);

        da.Fill(ds);       

        con.Open();

        cmd.ExecuteNonQuery();

        txtFirstName.Text = ds.Tables[0].Rows[0][2].ToString();

        txtMiddleName.Text = ds.Tables[0].Rows[0][4].ToString();

        txtLastName.Text = ds.Tables[0].Rows[0][3].ToString();

        txtMobile.Text = ds.Tables[0].Rows[0][10].ToString();

        txtOfficeEmail.Text = ds.Tables[0].Rows[0][12].ToString();

        txtOfficePhone.Text = ds.Tables[0].Rows[0][8].ToString();

        txtPersonnelEmail.Text = ds.Tables[0].Rows[0][13].ToString();

        txtWebSite.Text = ds.Tables[0].Rows[0][7].ToString();

        txtJobTitle.Text = ds.Tables[0].Rows[0][5].ToString();

        txtCompany.Text = ds.Tables[0].Rows[0][6].ToString();

        txtHomePhone.Text = ds.Tables[0].Rows[0][9].ToString();

        txtFax.Text = ds.Tables[0].Rows[0][11].ToString();

        txtAddress.Text = ds.Tables[0].Rows[0][14].ToString();

        con.Close();

    }

    protected void Main_Click(object sender, ImageClickEventArgs e)

    {

        Response.Redirect("AllRecord.aspx");

    }

} 




Figure 6: In updating the Record.

ShowSelectedRecord.aspx

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

 <!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>Individual Record</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <table cellpadding="0" cellspacing="0" border="1" width="90%" align="center" background="BackGround.jpg">

    <tr><td> <table cellpadding="0" cellspacing="0" width="70%" align="center" >

     <tr> <td align="center" style="border-bottom:2px solid;">
          <
asp:Label ID="lblName" runat="server" Text="Individual Record" Font-Bold="true"

                Font-Size="14pt" > </asp:Label> </td> </tr>

   

    <tr><td height="5px"></td></tr>

    <tr><td> <marquee behavior=alternate bgcolor="#ffcccc">
           <
asp:Label ID="lblNameHeading" runat="server" Font-Bold="true" ForeColor="#0000ff"> </asp:Label>
             
&nbsp; <asp:Label ID="lblLastNameHeading" runat="server"

                               Width="140px" Font-Bold="true" ForeColor="#0000ff" >
             </
asp:Label> </marquee></td> </tr>

    <tr><td height="5px"></td></tr>

   

    <tr><td> <table width="60%" align="center">

    <tr><td> <asp:Label ID="lblFirstname" runat="server" Width="140px" Text="First Name" Font-Bold="true">

                            </asp:Label>

            <asp:TextBox ID="txtFirsname" runat="server"> </asp:TextBox> </td> </tr>

     <tr><td height="5px"> </td></tr>

     

    <tr><td> <asp:Label ID="lblMiddleName" runat="server" Width="140px" Text="Middle Name" Font-Bold="true">

                            </asp:Label>

            <asp:TextBox ID="txtMiddleName" runat="server"> </asp:TextBox></td></tr>

     <tr><td height="5px"></td></tr>

    <tr><td> <asp:Label ID="lblLastName" runat="server" Width="140px" Text="Last Name" Font-Bold="true"> </asp:Label>

            <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox></td></tr> 

 

 <tr><td height="5px"></td></tr>

    <tr><td> <asp:Label ID="lblCompany" runat="server" Width="140px" Text="Company" Font-Bold="true">

                       </asp:Label>

            <asp:TextBox ID="txtCompany" runat="server"></asp:TextBox></td></tr>

 <tr><td height="5px"> </td></tr>

    <tr><td><asp:Label ID="lblJobTitle" runat="server" Width="140px" Text="Job Title" Font-Bold="true"> </asp:Label>

            <asp:TextBox ID="txtJobTitle" runat="server"></asp:TextBox></td></tr>

 <tr><td height="5px"></td></tr>

   <tr><td><asp:Label ID="lblMobile" runat="server" Width="140px" Text="Mobile" Font-Bold="true"></asp:Label>

            <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox></td></tr>

 <tr><td height="5px"></td></tr>

   <tr><td><asp:Label ID="lblPersonnelEmail" runat="server" Width="140px" Text="Personnel Email" Font-Bold="true">

                </asp:Label>

            <asp:TextBox ID="txtPersonnelEmail" runat="server"></asp:TextBox>

           

            </td></tr> <tr><td height="5px"></td></tr>

           

            <tr><td> <asp:Label ID="Label1" runat="server" Width="140px" Text="Address" Font-Bold="true">

                          </asp:Label>

            <asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine"></asp:TextBox>

           

            </td></tr>

            <tr><td height="5px"></td></tr>

            <tr><td> <asp:Button ID="btnAllRecord" runat="server" Text="Return On All Record"

                        Width="303px" OnClick="AllRecord_Click" /> </td></tr>

            </table></td></tr>

    </table></td></tr>   

    </table>   

    </div>

    </form>

</body>

</html> 


ShowSelectedRecord.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

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

{

    protected void Page_Load(object sender, EventArgs e)

    {

        record();      

    }

    string connection = @"Data Source=MCN0100;Initial Catalog=AddressBook; Uid=sa; Pwd=";

    SqlConnection con;

    SqlCommand cmd = new SqlCommand();

    SqlDataAdapter da;

    DataSet ds = new DataSet();

 

    public void record()

    {

        int ID = int.Parse(Session["ID"].ToString());

        con = new SqlConnection(connection);

        cmd.CommandText = "select * from record where ID="+ID;

        cmd.Connection = con;

        da = new SqlDataAdapter(cmd);

        da.Fill(ds);

        con.Open();

        cmd.ExecuteReader();

        if (ds.Tables[0].Rows.Count > 0)

        {

            txtFirsname.Text = ds.Tables[0].Rows[0][2].ToString();

            txtLastName.Text = ds.Tables[0].Rows[0][3].ToString();

            txtMiddleName.Text = ds.Tables[0].Rows[0][4].ToString();

            txtCompany.Text = ds.Tables[0].Rows[0][6].ToString();

            txtJobTitle.Text = ds.Tables[0].Rows[0][5].ToString();

            txtMobile.Text = ds.Tables[0].Rows[0][10].ToString();

            txtPersonnelEmail.Text = ds.Tables[0].Rows[0][13].ToString();

            lblNameHeading.Text = ds.Tables[0].Rows[0][2].ToString();

            lblLastNameHeading.Text = ds.Tables[0].Rows[0][3].ToString();
            txtAddress.Text== ds.Tables[0].Rows[0][14].ToString();

        }

        else

        {

            Response.Write("No Record");

        }

        con.Close();

    }

    protected void AllRecord_Click(object sender, EventArgs e)

    {

        Response.Redirect("AllRecord.aspx");

    }

}



Figure 7: Selected Address.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Rahul Kumar Saxena
Rahul shows great interests in working with Microsoft technologies. He specializes in the implementation of DataBase & Graphics. His area of expertise includes: C#, ASP.NET,ADO.NET,Windows Forms & Web Services. He hails from background , Master's in Computer Application. With programming he loves photography, traveling and reading books.
(Talabpur*)
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Nevron Gauge for SharePoint
Become a Sponsor
 Comments
Appreaciated by kim On February 7, 2008
Good one!!! excellnet job
Reply | Email | Modify 
Re: Appreaciated by Rahul Kumar On February 14, 2008
Thanx KIM
Reply | Email | Modify 
Re: Re: Appreaciated by akhil On December 13, 2009
 can u send me online addressbook ki project report as soon as possible i didn't any matter on it
Reply | Email | Modify 
Re: Appreaciated by Rahul Kumar On August 18, 2008
Thanx KIM
Reply | Email | Modify 
asp.net by YERRIPILLI POTT On February 15, 2008
Hello Raahul, how are you? I have visited the dotnetheaven.com to learn the basic asp.net concepts, there I found your article, it is clearly mentioned , it is for the beginners. I want to develop the asp.net applications. In addition to this, I am developing c# programs at home. This is very interesting. Thank your very much. This is my email ypsrinivasarao_730126@hotmail.com
Reply | Email | Modify 
Re: asp.net by Rahul Kumar On February 18, 2008
Thanx
Reply | Email | Modify 
Very helpful by rabi narayan On October 23, 2008
Hi rahul, I am a VC++ developer and recently moved towards doing some web applications as per the requirement, So i wanted some examples which will give me a overal flow of asp .net application. And i checked your posts and those are very helpful for me getting some good knowledge. Thanks very much.....
Reply | Email | Modify 
Re: Very helpful by Rahul Kumar On December 18, 2008
Thanx RAVI
Reply | Email | Modify 
Appreaciated by Hashim On April 4, 2009
Really good one! for new comer
Reply | Email | Modify 
Re: Appreaciated by Rahul Kumar On April 7, 2009
Thanx Hasim for comment
Reply | Email | Modify 
Re: Re: Appreaciated by nauman On November 22, 2009
rahul bhai you done great job i am devloping my bachlor dagree project in asp.net can you help me kindly contact me on naumankhattak@gmail.com may apke email ka wait krunga i will send you my project proposal
thanks nauman khattak islamabad pakistan plz rahul bhaia email me
Reply | Email | Modify 
appreaciated by sandeep On April 18, 2009
hi buddy it solve my prob??????????????
Reply | Email | Modify 
Optmized Search Page Code by Shruti On May 12, 2009
Hi Rahul,

   Have liked your article....its a good way to start for asp.net 2.0 concepts

   I have a suggestion with the code written in search...u have placed buttons besides each textbox....instead of that we can keep one button...and in that button click following code can be written ...i have appended conditions in "and" clause...depending upon our requirement we can change it.....

no need to write different evevnts for each textbox....

protected void btnSearch_click(object sender, EventArgs e)
{

StringBuilder whereCondition = new StringBuilder() ;
foreach (Control ctlr in Page.Controls)
{
foreach(Control c in ctlr.Controls)
{
if (c is TextBox)
{
TextBox txt = c as TextBox;
if (txt.Text != string.Empty)

{

switch (txt.ID)

{

case "txtIDSearch":

whereCondition.Append("ID like " + txt.Text);

break;

case "txtFirstNameSearch":

if (string.Empty != whereCondition.ToString())

{

whereCondition.Append("and");

}

whereCondition.Append(" FirstName like '" + txtFirstNameSearch.Text + "'");

break;

case "txtLastNameSearch":

if (string.Empty != whereCondition.ToString())

{

whereCondition.Append("and");

}

whereCondition.Append(" LastName like '" + txtLastNameSearch.Text + "'");

break;

case "txtEmailSearch":

if (string.Empty != whereCondition.ToString())

{

whereCondition.Append("and");

}

whereCondition.Append(" PersonelEmail like '" + txtEmailSearch.Text + "'");

break;

}

}

}

}

}

commandSearch = "select * from Record where" + whereCondition.ToString();

showSearchRecord();

Also in many pages you have created a connection string and dataadapter,command object.....we can create a generic class and place a code for once...for example 

public SqlConnection Connect()

{

conn = new SqlConnection(@"Data Source=;Initial Catalog=; Uid=sa; Pwd=");

conn.Open();

return conn;

}

public DataSet ExecuteCommand(string query)

{

DataSet ds = new DataSet();

SqlDataAdapter sda = new SqlDataAdapter(query, conn);

sda.Fill(ds);

return ds;

}

public void InsertData(string query)

{

SqlCommand cmd = new SqlCommand();

cmd.CommandText = query;

cmd.Connection = conn;

cmd.ExecuteNonQuery();

conn.Close();

}



  
Reply | Email | Modify 
Re: Optmized Search Page Code by Rahul Kumar On May 14, 2009
Yes Shruti u can do it in this way,
Thanx to visit and comment
Reply | Email | Modify 
Nice Artical by Yogesh On May 22, 2009
Hi,
This is such a nice artical.
I m new comer in .NET, I would like to know how to use databound controls in template fields in gridview. I facing proble while binding it.
Please send me needful solution. I will wait for ur reply.

Thanks again for nice artical.
bye.
Reply | Email | Modify 
Re: Nice Artical by Rahul Kumar On March 22, 2010
Hi
Reply | Email | Modify 
thanks by yogesh On September 13, 2009
hey rahul u r geinous it is nice one thanks for providing very good and helping articles .
Reply | Email | Modify 
Errors by Nelson On October 22, 2009
I receive this error
http://i35.tinypic.com/jzy0zo.gif

And database looks like this
http://i34.tinypic.com/10fp5bs.jpg

What may be the problem?
Reply | Email | Modify 
how to connect database by suyash On March 20, 2010
hello rahul
can u tell me how to connect database in this project
Reply | Email | Modify 
Re: how to connect database by Rahul Kumar On March 22, 2010
Hi Suyash u can find database file inside App_Data folder and in config file change connection string.
 
And u can find my more projects here....

http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/494/Default.aspx?ArticleID=5f5c2f2d-c1a5-48f4-8183-1551829b45d3
Reply | Email | Modify 
hi by AKSHAT On April 24, 2010

hi...i have downloaded this project ....but i am unable to connect sqlserver with this ....

Can u please tell me the steps to do so as i am a beginner.

Thanks and Regards,

akshat

Reply | Email | Modify 
hi by AKSHAT On April 24, 2010

hi ,


i have downloaded the project "Address book" but i am unable to run it successfully, the problem is with SQLServer connection .Can you please guide me step by step  method to change connection string and connect to the SQLserver as i am beginner. 

Thanks and Regards,

Akshat


Reply | Email | Modify 
thanks by Preety On June 5, 2010
thanks buddy, i badly need a project on dot net for last 3-4 days.....thanks a lot
Reply | Email | Modify 
Re: thanks by Rahul Kumar On June 9, 2010
Welcome DEAR...
Reply | Email | Modify 
Suggestion by vikash On June 23, 2010
Hi rahul...gr8 job...bt it wud better if u add a feature for storing and displaying contact pic also..:)
Reply | Email | Modify 
Feedback abt project by manas On August 13, 2010
Great job Rahul,i m a great fan of yours.
                                           Thanks yaar
                                           yours manas
Reply | Email | Modify 
online address book by Mohammad On December 4, 2010
Thanks its very nice
Reply | Email | Modify 
nice by vijay On October 14, 2011
nice code dear, well done
Reply | Email | Modify 
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.