Full width home advertisement

Post Page Advertisement [Top]


Step-1: Create New Website .

Step-2: Create a new database.

Step-3: Create a new table that you want to display in repeater control.

Step-4: Fill the table with records.


Step-5 Take a repeater cntrol from data.

Step-6: on Source Design your repeater control.

Step-7: Write Down this code on code behind.

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

public partial class RepeaterControl : System.Web.UI.Page
{
    SqlConnection cn;
    SqlCommand cmd;
    string con = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\Alltools\App_Data\bk.mdf;Integrated Security=True";
    protected void Page_Load(object sender, EventArgs e)
    {

        show();
     
    }
//Function for data shiw in repeater control.
    public void show()
    {
        cn = new SqlConnection(con);
        cmd = new SqlCommand("select * from demo", cn);
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);     
        Repeater1.DataSource = dt;
        Repeater1.DataBind();
     

    }
}

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib