Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate event calendar 1

Status
Not open for further replies.

waely

Programmer
Dec 7, 2003
227
US
Hi,
I'm trying to populate a calendar with events stored in access db. I'm using vb.net and my date format is 00/00/0000. I don't need to add or edit events; I only want to display those events in my calendar.

your tips are highly appreciated and thanks in advace for you help.
 
You could use this
Code:
<asp:Calendar id=&quot;Calendar1&quot; runat=&quot;server&quot; OnDayRender=&quot;MyDayRender&quot;></asp:Calendar>


with the event

    Sub MyDayRender(ByVal source As Object, ByVal e As DayRenderEventArgs)
        Dim x As New Table()
        Dim i As Integer
        For i = 1 To 3
            Dim y As New TableRow()
            Dim z As New TableCell()
            z.Text = &quot;Event &quot; & i
            y.Cells.Add(z)
            x.Rows.Add(y)
        Next
        e.Cell.Controls.Add(x)
    End Sub

Here you could query database for what you want
I've used a simple table with 3 rows.


________
George, M
 
thanks george, I use the following codes to dislplay the data in datagrid

Dim strConn As String = &quot;Provider=Microsoft.Jet.OLEDB.4.0; data source=&quot; & Server.MapPath(&quot;croc.mdb&quot;)
Dim strSQL As String = &quot;select * from concerts order by date&quot;

Dim Conn As New OleDbConnection(strConn)
Dim Cmd As New OleDbCommand(strSQL, Conn)
Conn.Open()
DataGrid1.DataSource = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)DataGrid1.DataBind()

so where do I place the query and connection strings?
thanks so much for your help
 
Ah you using DataGrid? You want to display in DataGrid?

________
George, M
 
in the mean time I display the information in datagrid for myself but for my visitores i want to display the data in a calendar.

thanks
 
Use the code i posted with this event function.
Code:
    Sub MyDayRender(ByVal source As Object, ByVal e As DayRenderEventArgs)
        Dim x As New Table()
        Dim oCon As OleDbConnection
        Dim oComm As OleDbCommand
        Dim strMap As String
        Dim strSql As String
        Dim strCon As String
        Dim ident As Integer
        strMap = Server.MapPath(&quot;croc.mdb&quot;)
        strCon = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & strMap
        oCon = New OleDbConnection(strCon)
        oCon.Open()
        strSql = &quot;select * from concerts where date=#&quot; & e.Day.Date & &quot;# order by date&quot;
        oComm = New OleDbCommand(strSql, oCon)
        Dim DR As OleDbDataReader = oComm.ExecuteReader()
        Dim i As Integer = 1
        While (DR.Read())
            Dim y As New TableRow()
            Dim z As New TableCell()
            z.Text = &quot;<b>Event &quot; & i & &quot;</b>: &quot; & DR.Item(&quot;Eventname&quot;)
            y.Cells.Add(z)
            x.Rows.Add(y)
            i += 1
        End While
        oCon.Close()
        e.Cell.Controls.Add(x)
    End Sub

________
George, M
 
thanks George........... you're the man
 
Does anyone know how to set the Calendar control's cell to a fixed width and height?? When adding a label, image or literal control to the cell, the height and width changed, which making the calender cell wider in width and length.
This has givning me a big headache.

If anyone knows how to solve this problem, please let me know.

Much is appreaciated.
Laic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top