I have created a RadGridView in my application to use as an employee attendance calendar. The datasource is a SQL Server table with 1 column for the name of the month and 31 columns for the days of the month. In the database only the MonthName column has data in it; one record for each month. The columns for the days of the month are empty in the database. Basically this is just a template.
The day-of-the-month columns in the RadGridView are populated using a SQLDataReader. Like this;
Is it possible to use a similar approach to populate the Cells/TextBox's in a report table?
If not, is it possible to use a RadGridView as the datasource for a report table?
I am open to other suggestions.
The day-of-the-month columns in the RadGridView are populated using a SQLDataReader. Like this;
Private Sub FillCalendar()
Dim newFont = New Font("Calibri", 7.0F, FontStyle.Bold)
Dim EE As Integer
Dim vbYear As Integer
Dim Incident As String
Dim ColIndex As Integer 'Day of the month, also the name of the column
Dim RowIndex As Integer ' Month of the year, also row index + 1
EE = CInt(RadTextBoxElement10.Text) ' Employee id #
vbYear = CInt(RadDropDownListElement1.SelectedIndex + 2007) 'Year for calendar
'connection string and mysqlconnect
Dim connstring As String = ("Data Source=MyServer\SQLINSTANCE;Initial Catalog=DATABASENAME;Persist Security Info=True;User ID=MYUSER;Password=MYPASS")
Dim conn As New SqlConnection(connstring)
Dim selectSQL As String
'create selection query
selectSQL = ("Select aDay, aMonth, Incidents From View_AttCombined Where (GPID like '" & EE & "') and (aYear like '" & vbYear & "')")
'create selection command
Dim cmd As New SqlCommand(selectSQL, conn)
'set cmd property
cmd.CommandType = CommandType.Text
'open database
conn.Open()
'create and execute the reader
Dim myreader As SqlDataReader = cmd.ExecuteReader
While myreader.Read
ColIndex = myreader.GetInt32(0)
RowIndex = myreader.GetInt32(1) - 1
Incident = myreader.GetString(2)
Me.RadGridView1.Rows(RowIndex).IsCurrent = True
Me.RadGridView1.Columns(ColIndex).IsCurrent = True
Me.RadGridView1.CurrentCell.Value = Incident
If Len(Me.RadGridView1.CurrentCell.Value) > 3 Then
Me.RadGridView1.CurrentCell.Font = newFont
Else
End If
End While
conn.Close()
Me.AttendanceTableAdapter.Fill(Me.AttendanceDataSet.Attendance, CInt(RadTextBoxElement10.Text), CInt(RadDropDownListElement1.SelectedIndex + 2007))
Me.AttCalCommentsTableAdapter.Fill(Me.CalCommentDataSet.AttCalComments, CInt(RadTextBoxElement10.Text), CInt(RadDropDownListElement1.SelectedIndex + 2007))
Me.RadGridView1.CurrentRow = Me.RadGridView1.Rows(0)
Me.RadGridView1.CurrentColumn = Me.RadGridView1.Columns(1)
End Sub
Is it possible to use a similar approach to populate the Cells/TextBox's in a report table?
If not, is it possible to use a RadGridView as the datasource for a report table?
I am open to other suggestions.