How To create Event Calendar???

How To create Event Calendar???

if you want to create event on calendar control .Make sure firstly use EventCalendar.dll file and find on google write down EventCalendar.dll and then write down code as under below.

 <asp:GridView ID="gvSelectedDateEvents" runat="server" Width="100%">
</asp:GridView>
<ECalendar:EventCalendar ID="Calendar1" runat="server" BackColor="White" BorderColor="Silver"
BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="500px"
Width="800px" FirstDayOfWeek="Monday" NextMonthText="Next &gt;" PrevMonthText="&lt; Prev"
SelectionMode="DayWeekMonth" ShowGridLines="True" NextPrevFormat="ShortMonth"
ShowDescriptionAsToolTip="True" BorderStyle="Solid" EventDateColumnName="" EventDescriptionColumnName=""
EventHeaderColumnName="" OnSelectionChanged="Calendar1_SelectionChanged">
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" />
<SelectorStyle BorderColor="#404040" BorderStyle="Solid" />
<DayStyle HorizontalAlign="Left" VerticalAlign="Top" Wrap="True" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="#333333" Font-Bold="True" VerticalAlign="Bottom" />
<DayHeaderStyle BorderWidth="1px" Font-Bold="True" Font-Size="8pt" />
<TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True"
Font-Size="12pt" ForeColor="#333399" HorizontalAlign="Center" VerticalAlign="Middle" />
</ECalendar:EventCalendar>

Write Down Code in Code behind page
 private DataTable GetEvents()
{
DataTable dt = new DataTable();
dt.Columns.Add("EventDate",Type.GetType("System.DateTime"));
dt.Columns.Add("EventHeader",Type.GetType("System.String"));
dt.Columns.Add("EventDescription",Type.GetType("System.String"));

DataRow dr;

// Last Week's Events
dr = dt.NewRow();
dr["EventDate"] = DateTime.Now.AddDays(-7);
dr["EventHeader"] = "My Last Week's Event 1";
dr["EventDescription"] = "My Last Week's Event 1 Description";
dt.Rows.Add(dr);
return dt;
}
protected void Page_Load(object sender, EventArgs e)
{
Calendar1.EventDateColumnName = "EventDate";
Calendar1.EventDescriptionColumnName = "EventDescription";
Calendar1.EventHeaderColumnName = "EventHeader";

Calendar1.EventSource = GetEvents();
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
SelectedDatesCollection theDates = Calendar1.SelectedDates;
DataTable dtEvents = Calendar1.EventSource;

DataTable dtSelectedDateEvents = dtEvents.Clone();
DataRow dr;

foreach(DataRow drEvent in dtEvents.Rows)
foreach(DateTime selectedDate in theDates)
if ((Convert.ToDateTime(drEvent[Calendar1.EventDateColumnName])).ToShortDateString() == selectedDate.ToShortDateString() )
{
dr = dtSelectedDateEvents.NewRow();
dr[Calendar1.EventDateColumnName] = drEvent[Calendar1.EventDateColumnName];
dr[Calendar1.EventHeaderColumnName] = drEvent[Calendar1.EventHeaderColumnName];
dr[Calendar1.EventDescriptionColumnName] = drEvent[Calendar1.EventDescriptionColumnName];
dtSelectedDateEvents.Rows.Add(dr);
}
gvSelectedDateEvents.DataSource = dtSelectedDateEvents;
gvSelectedDateEvents.DataBind();

}

If you have any doubt regarding this post then comment this blog.
Ebook Download
View all
Learn
View all