search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Displaying from other table

Asked by Dragan
8 years ago.

I use this code, with this in calendar only display event name, event start, event end, now i want to display more value in Calendar from other table: p.ime. how can i do that?

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstDayOfWeek(new DateTime(2012, 09, 17));
DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days);
DataBind();
}

}

protected DataTable dbGetEvents(DateTime start, int days)
{

SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=Korisnik;Integrated Security=True";
SqlDataAdapter da = new SqlDataAdapter("SELECT e.id, e.name, e.eventstart, e.eventend, p.ime AS 'Person Name' FROM Event e INNER JOIN RegistracijaKorisnik p ON e.PersonID = p.id WHERE NOT ((e.eventend <= @start) OR (e.eventstart >= @end ))", con);
da.SelectCommand.Parameters.AddWithValue("start", start);
da.SelectCommand.Parameters.AddWithValue("end", start.AddDays(days));

DataTable dt = new DataTable();
da.Fill(dt);
return dt;

}

Answer posted by Dan Letecky [DayPilot]
8 years ago.

You can customize the event HTML using BeforeEventRender event handler. The original DB row is accessible using e.DataItem property.

Example:

    protected void DayPilotCalendar1_BeforeEventRender(object sender, DayPilot.Web.Ui.Events.Calendar.BeforeEventRenderEventArgs e)
    {
        string color = e.DataItem["color"] as string;
        if (!String.IsNullOrEmpty(color))
        {
            e.DurationBarColor = color;
        }
        e.InnerHTML += " ime: " +e.DataItem["ime"] as string;
    }
Comment posted by Dragan
8 years ago.

Thanks i put this line in code but now give me this error: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ime'. Can you tell me what to write in my code in the first post to show me the "ime" value in the calendar.

Answer posted by Dragan
8 years ago.

I solved the problem i delete AS 'Person Name' from SELECT and add this DataItemField="ime" in the tag DayPilot:DayPilotCalenda

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.