by Gehan Fernando (47 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Fri 14th November 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Use Data Repeater control to display huge collection data very easily.
API Declarations
.Data
.Data.SqlClient
'Author :- Gehan Fernando
'Description :- Use DataRepeator Control
'Date :- 14/Nov/2008
'Mail :- [email protected] , [email protected]
'Note :- before you run install Visual Basic .NET Power Tools from microsoft site
Public Class FormDataRepeater
Private _emptable As DataTable = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Cursor = Cursors.WaitCursor
Try
_emptable = Employees.EmployeesData().Tables(0)
TextBoxFirstName.DataBindings.Add("Text", _emptable, "FirstName")
TextBoxLastName.DataBindings.Add("Text", _emptable, "LastName")
TextBoxAddress.DataBindings.Add("Text", _emptable, "Address")
TextBoxNotes.DataBindings.Add("Text", _emptable, "Notes")
PictureBoxEmployee.DataBindings.Add("Image", _emptable, "Photo")
DataRepeaterEmployee.DataSource = _emptable
Catch ex As Exception
MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Me.Cursor = Cursors.Default
End Sub
Private Sub DataRepeaterEmployee_DrawItem(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeaterEmployee.DrawItem
If e.DataRepeaterItem.ItemIndex Mod 2 = 0 Then
e.DataRepeaterItem.BackColor = Color.FromArgb(213, 224, 211)
Else
e.DataRepeaterItem.BackColor = SystemColors.Control
End If
End Sub
End Class
Public Class Employees
Private Shared _con As SqlConnection = Nothing
Private Shared _com As SqlCommand = Nothing
Private Shared _dap As SqlDataAdapter = Nothing
Private Shared _dset As DataSet = Nothing
Private Shared _sqlstr As String = "Data Source=MYPC\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
Public Shared Function EmployeesData() As DataSet
Try
_con = New SqlConnection(_sqlstr)
_con.Open()
_com = New SqlCommand()
With _com
.Connection = _con
.CommandType = CommandType.Text
.CommandText = "SELECT FirstName,LastName,Address,Photo,Notes FROM Employees ORDER BY FirstName,LastName"
End With
_dap = New SqlDataAdapter(_com)
_dset = New DataSet("DSetEmployees")
_dap.Fill(_dset)
Catch ex As Exception
_dset = Nothing
Throw ex
End Try
Return _dset
End Function
End Class
No comments have been posted about Use Data Repeater control to display huge collection data very easily.. Why not be the first to post a comment about Use Data Repeater control to display huge collection data very easily..