I am new to ASP.NET and am trying to learn it the best that I can. I am trying to add some code in the If IntRowIndex > -1 statement to mark an item SELECTED before adding it to the CheckBoxList. Where I would like the code to go is marked "***** Make ShiftCode SELECTED *****" The code is pasted below. Thanks, in advance, for any assistance.
<%@ Debug = "True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<Script Runat="Server">
Sub Page_Load( s As Object, e As EventArgs )
Dim NumberOfEmployees As Integer
Dim EmployeeSelected As Integer
Dim DayNumber As Integer = 1
Dim ShiftCode As String
Dim conEmployees As OleDbConnection
Dim cmdSelectCount As OleDbCommand
Dim cmdSelectRubyShifts As OleDbCommand
Dim dstEmployeeAvailability As DataSet
Dim dadEmployeeAvailability As OleDbDataAdapter
Dim dvwEmployeeAvailability As DataView
Dim arrValues(1) As Object
Dim IntRowIndex As Integer
Dim cmdSelectEmployees as OleDbCommand
Dim dtrEmployees as OleDbDataReader
Dim dtrRubyShifts as OleDbDataReader
conEmployees = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=C:\Documents and Settings\User\Desktop\Code\Rubys\Rubys.mdb" )
conEmployees.Open()
cmdSelectRubyShifts = New OleDbCommand("Select * From RubysDailyShifts", conEmployees)
dtrRubyShifts = cmdSelectRubyShifts.ExecuteReader()
If dtrRubyShifts.HasRows Then
dstEmployeeAvailability = New DataSet()
dadEmployeeAvailability = New OleDbDataAdapter("Select * From FrontEmployeesAvailability where EmployeeID = 1", conEmployees)
dadEmployeeAvailability.Fill(dstEmployeeAvailabili ty, "FrontEmployeesAvailability")
dvwEmployeeAvailability = dstEmployeeAvailability.Tables("FrontEmployeesAvai lability").DefaultView()
dvwEmployeeAvailability.Sort = "DayNumber, ShiftCode"
While dtrRubyShifts.Read()
If dtrRubyShifts("DayNumber") > DayNumber Then
DayNumber += 1
End If
If dtrRubyShifts("AmountOfShiftCode") > 0 Then
arrValues(0) = DayNumber
arrValues(1) = dtrRubyShifts("ShiftCode")
IntRowIndex = dvwEmployeeAvailability.Find(arrValues)
ShiftCode = dtrRubyShifts("ShiftCode")
If IntRowIndex > -1 Then
***** Make ShiftCode SELECTED *****
End If
Select Case DayNumber
Case 1
chklEmployeeAvailabilityDay1.Items.Add(ShiftCode)
Case 2
chklEmployeeAvailabilityDay2.Items.Add(ShiftCode)
Case 3
chklEmployeeAvailabilityDay3.Items.Add(ShiftCode)
Case 4
chklEmployeeAvailabilityDay4.Items.Add(ShiftCode)
Case 5
chklEmployeeAvailabilityDay5.Items.Add(ShiftCode)
Case 6
chklEmployeeAvailabilityDay6.Items.Add(ShiftCode)
Case 7
chklEmployeeAvailabilityDay7.Items.Add(ShiftCode)
Case Else
End Select
End If
End While
Else
Response.Write("There were no records in the table RubysDailyShifts")
End If
conEmployees.Close()
End Sub
</Script>
<html>
<head><title>Employee Availability</title></head>
<body>
<form runat="server">
<table>
<tr><td align=center>Wed</td><td align=center>Thurs</td><td align=center>Fri</td><td align=center>Sat</td><td align=center>Sun</td><td align=center>Mon</td><td align=center>Tues</td></tr>
<td valign="top"><asp:CheckBoxList ID="chklEmployeeAvailabilityDay1" runat="server" /></td>
<td valign="top"><asp:CheckBoxList ID="chklEmployeeAvailabilityDay2" runat="server" /></td>
<td valign="top"><asp:CheckBoxList ID="chklEmployeeAvailabilityDay3" runat="server" /></td>
<td valign="top"><asp:CheckBoxList ID="chklEmployeeAvailabilityDay4" runat="server" /></td>
<td valign="top"><asp:CheckBoxList ID="chklEmployeeAvailabilityDay5" runat="server" /></td>
<td valign="top"><asp:CheckBoxList ID="chklEmployeeAvailabilityDay6" runat="server" /></td>
<td valign="top"><asp:CheckBoxList ID="chklEmployeeAvailabilityDay7" runat="server" /></td></tr>
</table>
</form>
</body>
</html>