Page

Query String in Asp.net with Example in C#, VB.NET

// Default.aspx //

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>QueryString Example in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div><b>QueryString Example</b></div><br />
<div>
<table>
<tr>
<td><b>UserId:</b></td>
<td><asp:TextBox ID="UserId" runat="server"/></td>
</tr>
<tr>
<td><b>UserName:</b></td>
<td><asp:TextBox ID="UserName" runat="server"/></td>
</tr>
<tr>
<td></td>
<td><asp:Button ID="btnSend" Text="Send Values" runat="server" onclick="btnsend_Click"/></td>
</tr>
</table>
</div>
</form>
</body>
</html>

// Default.aspx.cs //


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

using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnsend_Click(object sender, EventArgs e)
    {
        Response.Redirect("Description.aspx?UserId=" + UserId.Text + "&UserName=" + UserName.Text);
    }

}


// Description.aspx //

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>QueryString Example in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div><b>QueryString parameter Values in Description.aspx Page</b></div><br />
<div><b>UserId:</b><asp:Label ID="lblUserId" runat="server"/></div><br />
<div><b>UserName:</b><asp:Label ID="lblUserName" runat="server"/></div>
</form>
</body>

</html>

// Description.aspx.cs //

using System;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


public partial class Description : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lblUserId.Text = Request.QueryString["UserId"];
            lblUserName.Text = Request.QueryString["UserName"];
        }
    }

}



OUTPUT









Search records or data in gridview using jQuery

// example.aspx //


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div style="padding-left: 10px">
       <asp:Label ID="lblSearch" runat="server" Text="Search Text : " Font-Bold="true"></asp:Label> 
       <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox><asp:Button ID="btnSearch"
            runat="server" Text="Search" />
        <asp:Label ID="lblMessage" runat="server" Text="No Record Found" Font-Bold="true" ForeColor="Red" style="display:none"></asp:Label>
         <asp:GridView ID="grdDemoGrid" runat="server" AutoGenerateColumns="False"
            DataKeyNames="ID" DataSourceID="SqlDataSource1" Width="500px" style="margin-top:10px">
            <HeaderStyle CssClass="GridHeader" />
            <RowStyle CssClass="GridRow" />
            <AlternatingRowStyle CssClass="GridAltRow" />
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True"
                    SortExpression="ID" />
                <asp:BoundField DataField="FName" HeaderText="First Name" SortExpression="FName" />
                <asp:BoundField DataField="LName" HeaderText="Last Name" SortExpression="LName" />
                <asp:BoundField DataField="Email" HeaderText="Email Id" SortExpression="Email" />
            </Columns>
         
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:TestTableConnectionString %>" 
            SelectCommand="SELECT [ID], [FName], [LName], [Email] FROM [UserTable]">
        </asp:SqlDataSource>
    </div>
    </div>
    </form>
</body>
</html>


jQuery/ Java Script Section with CSS

<style type="text/css">
       .GridHeader
        {
            background-color: #808080;
            color: #ffffff;
            font-weight: bold;
            font-size: 15px;
        }
        .GridRow
        {
            background-color: #ffffff;
            font-size: 13px;
        }
        .GridAltRow
        {
            background-color: #d3d3d3;
            font-size: 13px;
        }
    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#<%=btnSearch.ClientID %>').click(function(e) {
                SearchGridData();
                e.preventDefault();
            });
        });
        function SearchGridData() {
            var counter = 0;
            //Get the search text
            var searchText = $('#<%=txtSearch.ClientID %>').val().toLowerCase();
            //Hide No record found message
            $('#<%=lblMessage.ClientID %>').hide();
            //Hode all the rows of gridview
            $('#<%=grdDemoGrid.ClientID %> tr:has(td)').hide();
            if (searchText.length > 0) {
                //Iterate all the td of all rows
                $('#<%=grdDemoGrid.ClientID %> tr:has(td)').children().each(function() {
                    var cellTextValue = $(this).text().toLowerCase();
                    //Check that text is matches or not
                    if (cellTextValue.indexOf(searchText) >= 0) {
                        $(this).parent().show();
                        counter++;
                    }
                });
                if (counter == 0) {
                    //Show No record found message
                    $('#<%=lblMessage.ClientID %>').show();
                }
            }
            else {
                //Show All the rows of gridview
                $('#<%=grdDemoGrid.ClientID %> tr:has(td)').show();
            }
        }
    </script>


OUTPUT








How to use MultiView control in asp.net

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">  
    protected void Page_Load(object sender, System.EventArgs e) {  
        if(!Page.IsPostBack){  
            MultiView1.ActiveViewIndex = 0;  
           }  
    }  
    void NextImage(object sender, System.EventArgs e)  
    {  
        MultiView1.ActiveViewIndex += 1;  
    }  
    protected void Page_PreRender(object sender, System.EventArgs e) {  
        Label1.Text = "Beautiful Forest Image: " + (MultiView1.ActiveViewIndex + 1).ToString() + " of " + MultiView1.Views.Count.ToString();  
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>MultiView Control Simple Example</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>  
        <br /><br />  
        <asp:MultiView ID="MultiView1" runat="server">  
            <asp:View ID="View1" runat="server">  
                <asp:Image ID="Image1" runat="server" 
                    ImageUrl="~/pic/Alka Seltzer Lemon Effervescent.jpg" />  
                <br />  
                <asp:Button ID="Button1" runat="server" Text="Next Image" OnClick="NextImage" />  
            </asp:View>  
            <asp:View ID="View2" runat="server">  
                <asp:Image ID="Image2" runat="server" ImageUrl="~/pic/Buscopan Forte Tab.jpg" />  
                <br />  
                <asp:Button ID="Button2" runat="server" Text="Next Image" OnClick="NextImage" />  
            </asp:View>  
            <asp:View ID="View3" runat="server">  
                <asp:Image ID="Image3" runat="server" ImageUrl="~/pic/Charcotabes 250mg.jpg" />  
                <br />  
                <asp:Button ID="Button3" runat="server" Text="Next Image" OnClick="NextImage" />  
            </asp:View>  
            <asp:View ID="View4" runat="server">  
                <asp:Image ID="Image4" runat="server" ImageUrl="~/pic/d.jpg" />  
                <br />  
                <asp:Button ID="Button4" runat="server" Text="Next Image" OnClick="NextImage" />  
            </asp:View>  
            <asp:View ID="View5" runat="server">  
                <asp:Image ID="Image5" runat="server" ImageUrl="~/pic/Network.jpg" />  
            </asp:View>  
        </asp:MultiView>  
      
    </div>  
    </form>  
</body>  
</html>  

DataList Edit/Delete Operations in asp.net


// data.aspx //

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
     <style type="text/css">
        .btn
        {
            background-color: #033280;
            color: White;
            font-size: 12px;
            font-weight: bold;
            padding-left: 5px;
        }
        a
        {
            text-decoration: none;
            font-weight: normal;
        }
        a:hover
        {
            text-decoration: underline;
        }
        .txt
        {
            font-size: 14px;
            font-weight: bold;
            padding-left: 5px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
   <div>
        <table width="500" cellpadding="0" cellspacing="0" align="center">
            <tr>
                <td colspan="2" height="40">
                     
                </td>
            </tr>
            <tr>
                <td colspan="2" height="40">
                    <b>DataList Edit/Delete Operations</b>
                </td>
            </tr>
            <tr>
                <td colspan="2" height="40">
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2" bgcolor="#FBF4E0">
                    <asp:DataList ID="dlData" runat="server" OnEditCommand="dlData_EditCommand" DataKeyField="eno"
                        OnCancelCommand="dlData_CancelCommand" OnDeleteCommand="dlData_DeleteCommand"
                        OnUpdateCommand="dlData_UpdateCommand">
                        <HeaderTemplate>
                            <table width="600" align="center" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td height="30" class="btn">
                                        Employee No.
                                    </td>
                                    <td class="btn">
                                        Employee Name
                                    </td>
                                    <td class="btn">
                                        Salary
                                    </td>
                                    <td colspan="2" class="btn" align="left">
                                        Command
                                    </td>
                                </tr>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                <td height="40" class="txt">
                                    <%#Eval("id")%>
                                </td>
                                <td class="txt">
                                    <%#Eval("name")%>
                                </td>
                                <td class="txt">
                                    <%#Eval("salary")%>
                                </td>
                                <td class="txt">
                   <asp:LinkButton ID="lnkEdit" runat="server" CommandName="edit" Text="Edit"></asp:LinkButton>
                                </td>
                                <td class="txt">
                      <asp:LinkButton ID="lnkDelete" runat="server" CommandName="delete" Text="Delete"
                                        OnClientClick="return confirm('Are you sure want delete this record?')"></asp:LinkButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <tr>
                                <td height="40" class="txt">
                                    <%#Eval("id")%>
                                </td>
                                <td>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%#Eval("name")%>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Employee Name cannot be blank!"
                                        ControlToValidate="TextBox2" Display="None"></asp:RequiredFieldValidator>
                                </td>
                                <td>
                     <asp:TextBox ID="TextBox3" runat="server" Text='<%#Eval("salary")%>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Employee Salary cannot be blank!"
                                        ControlToValidate="TextBox3" Display="None"></asp:RequiredFieldValidator>
                                </td>
                                <td class="txt">
                    <asp:LinkButton ID="lnkupdate" runat="server" CommandName="update" Text="Update"></asp:LinkButton>
                                </td>
                                <td class="txt">
                 <asp:LinkButton ID="LinkButton1" runat="server" CommandName="cancel" Text="Cancel"
                                        CausesValidation="false"></asp:LinkButton>
                                </td>
                            </tr>
                        </EditItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:DataList>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

// data.aspx.cs //

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

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

    void bindList()
    {
        SqlConnection sqlcon = new SqlConnection("Data Source=.;Initial Catalog=asd;Integrated Security=True;");
        sqlcon.Open();
        SqlCommand sqlcmd = new SqlCommand("select * from emp", sqlcon);
        SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            dlData.DataSource = dt;
            dlData.DataBind();
        }
            sqlcon.Close();
    }
    protected void dlData_EditCommand(object source, DataListCommandEventArgs e)
    {
        dlData.EditItemIndex = e.Item.ItemIndex;
        bindList();
    }

    protected void dlData_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        SqlConnection sqlcon = new SqlConnection("Data Source=.;Initial Catalog=asd;Integrated Security=True;");
        string name = ((TextBox)e.Item.FindControl("TextBox2")).Text;
        string salary = ((TextBox)e.Item.FindControl("TextBox3")).Text;

        int id = Convert.ToInt32(dlData.DataKeys[e.Item.ItemIndex]);
        SqlCommand sqlcmd = new SqlCommand("update emp set empname='" + name + "',salary='" + salary+ "' where id='" + id + "'", sqlcon);
        sqlcon.Open();
        sqlcmd.ExecuteNonQuery();
        sqlcon.Close();
        dlData.EditItemIndex = -1;
        bindList();
    }

    protected void dlData_CancelCommand(object source, DataListCommandEventArgs e)
    {
        dlData.EditItemIndex = -1;
        bindList();
    }
    protected void dlData_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        SqlConnection sqlcon = new SqlConnection("Data Source=.;Initial Catalog=asd;Integrated Security=True;");
        int id = Convert.ToInt32(dlData.DataKeys[e.Item.ItemIndex]);
        SqlCommand sqlcmd = new SqlCommand("delete from emp where id='" + id + "'", sqlcon);
        sqlcon.Open();
        sqlcmd.ExecuteNonQuery();
        sqlcon.Close();
        bindList();
    }

}

// SQL Table //




// OUTPUT //







Creating Paging for a Repeater Control in ASP.Net


// fgh.aspx //


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
   
        <asp:Repeater ID="rptPages" Runat="server">
      <HeaderTemplate>
      <table cellpadding="0" cellspacing="0" border="0">
      <tr class="text">
         <td><b>Page:</b>&nbsp;</td>
         <td>
      </HeaderTemplate>
      <ItemTemplate>
         <asp:LinkButton ID="btnPage" CommandName="Page"  CommandArgument="<%#Container.DataItem %>"   CssClass="text"  Runat="server"><%# Container.DataItem %>
      </asp:LinkButton>&nbsp;                   
        </ItemTemplate>
      <FooterTemplate>
         </td>
      </tr>
      </table>
      </FooterTemplate>
      </asp:Repeater>
      <asp:Repeater ID="rptItems" runat="server">
      <HeaderTemplate>
      <ul>
      </HeaderTemplate>
      <ItemTemplate>
      <li><%# Eval("pkItemID") %>: <%# Eval("Description") %></li>
      </ItemTemplate>
      <FooterTemplate>
      </ul>
      </FooterTemplate>
      </asp:Repeater>
</form>

</body>
</html>


// fgh.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.SqlClient;
using System.Data;
using System.Drawing;
using System.Collections;

public partial class fgh : System.Web.UI.Page
{

    public int PageNumber
    {
        get
        {
            if (ViewState["PageNumber"] != null)
                return Convert.ToInt32(ViewState["PageNumber"]);
            else
                return 0;
        }
        set
        {
            ViewState["PageNumber"] = value;
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        rptPages.ItemCommand +=
           new RepeaterCommandEventHandler(rptPages_ItemCommand);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            LoadData();
    }

     private void LoadData()
   {
       SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=rnp;Integrated Security=True;");
      cn.Open();
      SqlDataAdapter da = new SqlDataAdapter("select * from ads", cn);
      DataTable dt = new DataTable();
      da.Fill(dt);
      cn.Close();
      PagedDataSource pgitems = new PagedDataSource();
      DataView dv = new DataView(dt);
      pgitems.DataSource = dv;
      pgitems.AllowPaging = true;
      pgitems.PageSize = 5;
      pgitems.CurrentPageIndex = PageNumber;
      if (pgitems.PageCount > 1)
      {
         rptPages.Visible = true;
         ArrayList pages = new ArrayList();
         for (int i = 0; i < pgitems.PageCount; i++)
         pages.Add((i + 1).ToString());
         rptPages.DataSource = pages;
         rptPages.DataBind();
      }
      else
         rptPages.Visible = false;
      rptItems.DataSource = pgitems;
      rptItems.DataBind();
   }
   void rptPages_ItemCommand(object source,
                             RepeaterCommandEventArgs e)
   {
      PageNumber = Convert.ToInt32(e.CommandArgument) - 1;
      LoadData();
   }

}

// SQL TABLE //


code for CheckBoxList control in asp.net

// default.aspx //

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.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">
<style type="text/css">
        .PnlDesign
        {
            border: solid 1px #000000;
            height: 150px;
            width: 330px;
            overflow-y:scroll;
            background-color: #EAEAEA;
            font-size: 15px;
            font-family: Arial;
        }
        </style>
        </style>
</head>
<body>

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

     <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatColumns="1"
            style="position:absolute; top: 890px; left: 10px; height: 699px; width: 257px;" 
            AutoPostBack="True" CellSpacing="1" CssClass="PnlDesign">

        </asp:CheckBoxList> 

    </form>
</body>

</html>


// default.aspx.cs //

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;

public partial class default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            FillQualCheckBoxList();
        }
}
 private void FillQualCheckBoxList()
    {
        SqlConnection con = new             SqlConnection(ConfigurationManager.ConnectionStrings["Pubs"].ConnectionString);
        SqlCommand cmd = new SqlCommand("Select * from category", con);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        cblCourses.DataSource = dt;
        cblCourses.DataTextField = "Name";
        cblCourses.DataValueField = "Id";
        cblCourses.DataBind();

                                
    }


// Add Code in web.config //

<connectionStrings>
<add name="Pubs" connectionString="Data Source=.;Initial Catalog=rnp;Integrated Security=True"/>
    
</connectionStrings>

// SQL Table //



How to use repeater in ASP.net

// default.aspx //


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ASP.net how to use repeater</title>
    <style type="text/css">
        #divEmployees
        {
            font-family:Arial, Verdana, Sans-Serif;
            font-size:12px;
            padding:10px;
            border:solid 1px #0066CC;
        }
        
        #divEmployees .detail
        {
            border-bottom:dashed 1px #0066CC;
            margin-bottom:10px;
            padding:10px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <fieldset>
            <h2>How to Use Repeater Control</h2>
        <div>
        <asp:Repeater ID="rptEmployees" runat="server">
            <HeaderTemplate>
                <div id="divEmployees">
            </HeaderTemplate>
            <ItemTemplate>
                <div class="detail">
                   <div>Name: <strong><%# Eval("FirstName") %> <%# Eval("LastName") %></strong></div>
                   <div>Address: <strong><%# Eval("Address") %></strong></div>
                   <div>State: <strong><%# Eval("State")%></strong></div>
                   <div>City: <strong><%# Eval("City")%></strong></div>
                   <div>Country: <strong><%# Eval("Country")%></strong></div>
                </div>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <div class="detail">
                   <div>Name: <strong><%# Eval("FirstName") %> <%# Eval("LastName") %></strong></div>
                   <div>Address: <strong><%# Eval("Address") %></strong></div>
                   <div>State: <strong><%# Eval("State")%></strong></div>
                   <div>City: <strong><%# Eval("City")%></strong></div>
                   <div>Country: <strong><%# Eval("Country")%></strong></div>
                </div>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </div>
            </FooterTemplate>
        </asp:Repeater>
        </div>
        </fieldset>
    </div>
    </form>
</body>
</html>


// default.aspx.cs //

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

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //You need to include using system.collections.generic
        List<Employee> lstEmployees = new List<Employee>();

        //Add Employee info to the collection
        lstEmployees.Add(new Employee()
        {
            FirstName = "Mark",
            LastName = "Arton",
            HomePhone = "000-000-0000",
            CellPhone = "000-000-0000",
            Address = "Lane 1 Suite # 2",
            State = "Connecticut",
            City = "New Hamden",
            Zipcode = "06514",
            Country = "USA"
        });

        lstEmployees.Add(new Employee()
        {
            FirstName = "Tony",
            LastName = "Jacob",
            HomePhone = "000-000-0000",
            CellPhone = "000-000-0000",
            Address = "Lane 1 Suite # 2",
            State = "N/A",
            City = "London",
            Zipcode = "2314",
            Country = "United Kingdom"
        });

        lstEmployees.Add(new Employee()
        {
            FirstName = "Robert",
            LastName = "Brown",
            HomePhone = "000-000-0000",
            CellPhone = "000-000-0000",
            Address = "Lane 1 Suite # 2",
            State = "N/A",
            City = "Melbourne",
            Zipcode = "AB8799",
            Country = "Australia"
        });

        //Assign data source to the repeater
        rptEmployees.DataSource = lstEmployees;

        //You need to rebind the repeater
        rptEmployees.DataBind();
    }
}

public class Employee
{
    public string FirstName { get; set; }

    public string LastName { get; set; }

    public string HomePhone { get; set; }

    public string CellPhone { get; set; }

    public string Address { get; set; }

    public string City { get; set; }

    public string Zipcode { get; set; }

    public string State { get; set; }

    public string Country { get; set; }
}

How to send an Email using C# – complete features

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using System.Net;
using System.Net.Mail;

public partial class Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=rnp;Integrated Security=True");
    SqlDataAdapter objDA = new SqlDataAdapter();
    DataSet objDS = new DataSet();
    DataTable objDT = new DataTable();
    Int32 TotalRecords = 0, CurrentRecord = 0;
 protected void Button1_Click(object sender, EventArgs e)
    {
 MailMessage msg;
        SqlCommand cmd = new SqlCommand();
        string ActivationUrl = string.Empty;
        string emailId = string.Empty;

        try
        {
            string date = DropDownList2.SelectedItem.Text + "/" + DropDownList3.SelectedItem.Text + "/" + DropDownList4.SelectedItem.Text;
            cmd = new SqlCommand("insert into Login (Name,DOB,Email_id,Passwd,Gender,Location,Mobile_no) values (@Name,@DOB,@Email_id,@Passwd,@Gender,@Location,@Mobile_no) ", con);

            cmd.Parameters.AddWithValue("@Name", TextBox1.Text.Trim());
            cmd.Parameters.AddWithValue("@DOB", date.Trim());
            cmd.Parameters.AddWithValue("@Email_id", TextBox2.Text.Trim());
            cmd.Parameters.AddWithValue("@Passwd", TextBox40.Text.Trim());
            cmd.Parameters.AddWithValue("@Gender", RadioButtonList1.SelectedValue.Trim());
            cmd.Parameters.AddWithValue("@Location", DropDownList5.SelectedValue.Trim());
            cmd.Parameters.AddWithValue("@Mobile_no", TextBox5.Text.Trim());

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            cmd.ExecuteNonQuery();

            //Sending activation link in the email
            msg = new MailMessage();
            SmtpClient smtp = new SmtpClient();
            emailId = TextBox2.Text.Trim();
            //sender email address
            msg.From = new MailAddress("xyz@gmail.com");
            //Receiver email address
            msg.To.Add(emailId);
            msg.Subject = "Confirmation email for account activation";
            //For testing replace the local host path with your lost host path and while making online replace with your website domain name
            ActivationUrl = Server.HtmlEncode("http://localhost:8345/medi/ActivateAccount.aspx?id=" + Fetchid(emailId) + "&Email_id=" + emailId);

            msg.Body = "Hi " + TextBox1.Text.Trim() 
            
            + "!\n Your Id Is : "  + "\n Your Password Is : " + TextBox40.Text.Trim() +

                "Thanks for showing interest and registring in <a href='http://www.eBusinessSolution.com'> eBusinessSolution.com<a> " +
                  " Please <a href='" + ActivationUrl + "'>click here to activate</a>  your account and enjoy our services. \nThanks!";
            msg.IsBodyHtml = true;
            smtp.Credentials = new NetworkCredential("sendermail@gmail.com", "password");
            smtp.Port = 25;
            smtp.Host = "smtp.gmail.com";
            smtp.EnableSsl = true;
            smtp.Send(msg);

            ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Confirmation Link to activate your account has been sent to your email address');", true);
        }
       
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Error occured : " + ex.Message.ToString() + "');", true);
            return;
        }
        finally
        {
            ActivationUrl = string.Empty;
            emailId = string.Empty;

            con.Close();
            cmd.Dispose();
        }
    }
    


    private string Fetchid(string emailId)
    {
        SqlCommand cmd = new SqlCommand();
        cmd = new SqlCommand("SELECT id FROM Login WHERE Email_id=@Email_id", con);
        cmd.Parameters.AddWithValue("@Email_id", emailId);
        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }
        string id = Convert.ToString(cmd.ExecuteScalar());
        con.Close();
        cmd.Dispose();
        return id;
    }
    }


// SQL Table //




    

    

Code For Image Slider in ASP.Net

   <script language="JavaScript" type="text/javascript">
<!--
         src = ["images/1.jpg", "images/2.jpg", "images/3.jpg", "images/4.jpg", "images/5.jpg", "images/6.jpg", "images/7.jpg", "images/8.jpg", "images/9.jpg", "images/10.jpg", "images/11.jpg"]

         url = ["    ", "    ", "    ", "     ","    ","    ","    ","    ","   ","   ","   "]
        duration = 4;

        ads = []; ct = 0;
        function switchAd() {
            var n = (ct + 1) % src.length;
            if (ads[n] && (ads[n].complete || ads[n].complete == null)) {
                document["Ad_Image"].src = ads[ct = n].src;
            }
            ads[n = (ct + 1) % src.length] = new Image;
            ads[n].src = src[n];
            setTimeout("switchAd()", duration * 1000);
        }
        function doLink() {
            location.href = url[ct];
        } onload = function () {
            if (document.images)
                switchAd();
        }

</script>


   <div style="position:absolute;  left:1117px; width:218px; height:300px; top:205px;">
    <a href="javascript:doLink();" onMouseOver="status=url[ct];return true;" onMouseOut="status=''">

<img name="Ad_Image" src="pics/1.jpg" border=2% 
     style="border-style: solid; border-color: #000000; height: 300px; top:588px; width: 218px;  margin-top: 6px;" >   &nbsp;</a>

    </div>