⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultcs.aspx.cs

📁 Telerik是很大的第三方软件制造商
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Telerik.WebControls;

namespace Telerik.ExamplesCSharp.RadCalendar.Functionality.DataBinding
{
	/// <summary>
	/// Summary description for DefaultCS.
	/// </summary>
	public class DefaultCS : Telerik.QuickStart.XhtmlPage
	{
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				RebindGrid();
			}
		}

		private DataTable DataSource
		{
			get
			{
				if (Session[Request.CurrentExecutionFilePath + "Dates"] == null)
				{
					DataTable table = new DataTable("Events");
					table.Columns.Add("Dates");
					table.Rows.Add(new object[]{new DateTime(2006, 3, 10)});
					table.Rows.Add(new object[]{new DateTime(2006, 3, 15)});
					table.Rows.Add(new object[]{null});
					table.Rows.Add(new object[]{System.DBNull.Value});
					table.Rows.Add(new object[]{new DateTime(2006, 4, 1)});	

					Session[Request.CurrentExecutionFilePath + "Dates"] = table;
				}
			
				return (DataTable) Session[Request.CurrentExecutionFilePath + "Dates"];
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
			this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
			this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			DataGrid1.EditItemIndex = e.Item.ItemIndex;

			RebindGrid();
		}

		private void RebindGrid()
		{
			DataGrid1.DataSource = DataSource;
			DataGrid1.DataBind();
		}

		private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			DataGrid1.EditItemIndex = -1;
			RebindGrid();
		}

		private void DataGrid1_UpdateCommand(object source, DataGridCommandEventArgs e)
		{
			RadDatePicker picker = (RadDatePicker) e.Item.FindControl("picker1");
			DateTime newDate = picker.SelectedDate;
			DataSource.Rows[e.Item.DataSetIndex]["Dates"] = newDate;

			DataGrid1.EditItemIndex = -1;
			RebindGrid();
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -