Home > DeveloperSection > Articles > DataRepeater Control in C#.Net

DataRepeater Control in C#.Net


C# C# 
Ratings:
2 Comment(s)
 23434  View(s)
Rate this:

DataRepeater Control in C#.Net

The DataRepeater control allows you to display rows of your data in a scrollable container giving you more flexibility and customization than standard grid controls.

How to use DataRepeater

Drag and drop DataRepeater control from toolbox on the window form.

DataRepeater Control in C#.Net

Drag and drop textbox in the DataRepeater Control to display data.

DataRepeater Control in C#.Net

BindData in DataRepeater

Code:

using System;

using System.Data;

using System.Data.SqlClient;

using System.Text;

using System.Windows.Forms;

 

namespace WindowsFormsApplication1

{

    public partial class frmDataRepeater : Form

    {

        public frmDataRepeater()

        {

            InitializeComponent();

        }

 

    private void frmDataRepeater_Load(object sender, EventArgs e)

        {

            //Connect to the Database

       string constring = "Server=(local);Database=my; User Id=sa; Password=sa";

            SqlConnection sqlcon = new SqlConnection(constring);

            //Open the connection

            sqlcon.Open();

            SqlCommand cmd = new SqlCommand();

            SqlDataAdapter da = new SqlDataAdapter();

            // Write the query

            cmd.CommandText = "select * from regform";

            da.SelectCommand = cmd;

            cmd.Connection = sqlcon;

            da.SelectCommand = cmd;

            //create a dataset

            DataSet ds = new DataSet();

            da.Fill(ds);

            //Close the connection

            sqlcon.Close();

            // Bind data to TextBox

            textBox1.DataBindings.Add("Text", da, "id");

            textBox2.DataBindings.Add("Text", da, "pass");

            textBox3.DataBindings.Add("Text", da, "name");

            dataRepeater1.Visible = true;

            dataRepeater1.DataSource = ds.Tables[0];

        }

    }

}

 

Data will bind to the DataRepeater when application run.

Run the project

DataRepeater Control in C#.Net

You can see next data by making scroll bar down.

 

DataRepeater Control in C#.Net


HOW TO DISPLAY A IMAGES IN DATAREPEATER CONTROL

By priya  on   5 years ago
HEY IF I HAD A IMAGE PATH IN DATABASE.. NOW I WANT TO DISPLAY IMAGES IN DATAREPEATER TAKING IMAGE PATH FROM DATABASE............. CAN U HELP ME OUT

THANKS
PRIYA

HOW TO DISPLAY A IMAGES IN DATAREPEATER CONTROL

By priya  on   5 years ago
Dim datatable1 As New DataTable

        datatable1.Columns.Add("imagepath")
        datatable1.Rows.Add("C:\Inetpub\wwwroot\images\001.jpg")
        datatable1.Rows.Add("C:\Inetpub\wwwroot\images\a.jpg")
        datatable1.Rows.Add("C:\Inetpub\wwwroot\images\AFGHANISTAN-UNREST-883723-01-02-204256.jpg")
        dr.DataSource = datatable1
        Dim r As DataTable = dr.DataSource

        pbPicture.ImageLocation = r.Rows.Item(i).Item(0).ToString
         pbPicture.Load()
        If r.Rows.Count - 1 <> i Then
            i += 1
        Else
            i = 0
        End If

I used the above code........ but its not displaying images in picturebox which placed in datarepeater.........
thanks
priya

Don't want to miss updates? Please click the below button!

Follow MindStick