Hi,
I have the auto generated dayName and date out... mean the top 2 rows out but now i need to get the name of employee from the sql database... After coding, the name came out as horizontal but i wan vertical is this possible???
Code:
Imports System.Data.OleDb
Imports System.Data
Partial Class Test
Inherits System.Web.UI.Page
Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ScheduleForm.mdb")
Sub TakeoutOutlets()
cnn.Open()
Dim cmd As New OleDbCommand
cmd.CommandText = "Select * from Outlets Order By OutletName"
cmd.Connection = cnn
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
ddl_out.DataValueField = "OutletName"
ddl_out.DataTextField = "OutletName"
ddl_out.DataSource = ds
ddl_out.DataBind()
cnn.Close()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
TakeoutOutlets()
For i As Integer = DateTime.Now.Year To DateTime.Now.Year + 9
'Populate DropDownList
'Year
Me.DropDownList1.Items.Add(New ListItem(i.ToString(), i.ToString()))
Next
For i As Integer = 1 To 12
'Month
Me.DropDownList2.Items.Add(New ListItem(i.ToString(), i.ToString()))
Next
End If
End Sub
Protected Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
If DropDownList1.SelectedItem.Text = "Select a Year" Or DropDownList2.SelectedItem.Text = "Select a month" Then
emsg.Text = "Please select a month and a year"
Else
Dim year As Integer = Convert.ToInt32(Me.DropDownList1.SelectedValue)
Dim month As Integer = Convert.ToInt32(Me.DropDownList2.SelectedValue)
Dim day_num As Integer = DateTime.DaysInMonth(year, month)
Dim a As New ArrayList()
Dim datelist As New ArrayList()
Dim daylist As New ArrayList()
Dim name As New ArrayList()
For i As Integer = 1 To day_num
Dim dt As New DateTime(year, month, i)
datelist.Add(dt.ToString("ddd"))
daylist.Add(dt.ToString("dd"))
Next
cnn.Open()
Dim sqlstr As String = "Select * from Schedule where outlets = '" + ddl_out.SelectedItem.Text + "'"
Dim cmd As New OleDbCommand(sqlstr, cnn)
Dim objDR As OleDbDataReader
objDR = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
While objDR.Read()
name.Add(objDR("EmpID"))
End While
cnn.Close()
a.Add(datelist)
a.Add(daylist)
a.Add(name)
Me.GridView4.DataSource = a
Me.GridView4.DataBind()
End If
End Sub
Protected Sub GridView4_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim a As ArrayList = TryCast(e.Row.DataItem, ArrayList)
e.Row.Cells.Clear()
If a IsNot Nothing Then
For Each s As String In a
Dim tc As New TableCell()
tc.Text = s
e.Row.Cells.Add(tc)
Next
End If
End Sub
End Class
Comment