private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here mycn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connStr"]); myda = new SqlDataAdapter ("Select * FROM kalender", mycn); myda.Fill (ds,"Table"); }
protected void CalendarDRender(object sender ,System.Web.UI.WebControls.DayRenderEventArgs e ) { // If the month is CurrentMonth if (! e.Day.IsOtherMonth ) { foreach (DataRow dr in ds.Tables[0].Rows) { if ((dr["dato"].ToString() != DBNull.Value.ToString())) { DateTime dtEvent= (DateTime)dr["dato"]; if (dtEvent.Equals(e.Day.Date)) { e.Cell.BackColor = Color.PaleVioletRed; } } } } //If the month is not CurrentMonth then hide the Dates else { e.Cell.Text = ""; } }
private void Calendar1_SelectionChanged(object sender, System.EventArgs e) { myda = new SqlDataAdapter("Select * from kalender where dato='" + Calendar1.SelectedDate.ToString() + "'", mycn); dsSelDate = new DataSet(); myda.Fill(dsSelDate, "AllTables"); if (dsSelDate.Tables[0].Rows.Count == 0 ) { DataGrid1.Visible = false; } else { DataGrid1.Visible = true; DataGrid1.DataSource = dsSelDate; DataGrid1.DataBind (); } }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here mycn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connStr"]); myda = new SqlDataAdapter ("Select * FROM kalender", mycn); myda.Fill (ds,"Table"); }
protected void CalendarDRender(object sender ,System.Web.UI.WebControls.DayRenderEventArgs e ) { // If the month is CurrentMonth if (! e.Day.IsOtherMonth ) { foreach (DataRow dr in ds.Tables[0].Rows) { if ((dr["dato"].ToString() != DBNull.Value.ToString())) { DateTime dtEvent= (DateTime)dr["dato"]; if (dtEvent.Equals(e.Day.Date)) { e.Cell.BackColor = Color.PaleVioletRed; } } } } //If the month is not CurrentMonth then hide the Dates else { e.Cell.Text = ""; } }
...med det her:
SqlConnection c = new SqlConnection(); c.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["connStr"]; c.Open(); SqlCommand sqlcommand = new SqlCommand(); sqlcommand.Connection = c; sqlcommand.CommandText = "Select * FROM kalender"; SqlDataAdapter sqldataadapter = new SqlDataAdapter(); sqldataadapter.SelectCommand = sqlcommand; DataSet dataset = new DataSet(); sqldataadapter.Fill(dataset); DataTable datatable = new DataTable(); datatable = dataset.Tables[0]; if (! e.Day.IsOtherMonth ) { foreach(DataRow dr in datatable.Rows) { if ((dr["dato"].ToString() != DBNull.Value.ToString())) { DateTime dtEvent= (DateTime)dr["dato"]; if (dtEvent.Equals(e.Day.Date)) { e.Cell.BackColor = Color.PaleVioletRed; } } } } else { e.Cell.Text = ""; }
Fedt det virkede. Men private void Calendar1_SelectionChanged(object sender, System.EventArgs e) virker stadig ikke. Det er som om metoden ikke aktiveres.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.