📄 defaultcs.aspx.cs
字号:
using System;
using System.Data;
using System.Data.OleDb;
using System.Web.UI.WebControls;
using Telerik.QuickStart;
using Telerik.WebControls;
namespace Telerik.GridExamplesCSharp.Styles.EditRowStyle
{
public abstract class DefaultCS : XhtmlPage
{
protected Telerik.WebControls.RadGrid RadGrid1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.RadioButton RadioButton1;
protected System.Web.UI.WebControls.RadioButton RadioButton2;
private void RadGrid1_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)
{
OleDbConnection MyOleDbConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("~/Grid/Data/Access/Nwind.mdb"));
OleDbDataAdapter MyOleDbDataAdapter = new OleDbDataAdapter();
MyOleDbDataAdapter.SelectCommand = new OleDbCommand("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers", MyOleDbConnection);
DataTable myDataTable = new DataTable();
MyOleDbConnection.Open();
try
{
MyOleDbDataAdapter.Fill(myDataTable);
}
finally
{
MyOleDbConnection.Close();
}
RadGrid1.DataSource = myDataTable;
}
private void RadioCheckedChanged(object sender, System.EventArgs e)
{
switch((sender as RadioButton).ID)
{
case "RadioButton1":
{
RadGrid1.MasterTableView.EditMode = GridEditMode.EditForms;
RadioButton2.Checked = false;
break;
}
case "RadioButton2":
{
RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;
RadioButton1.Checked = false;
break;
}
}
RadGrid1.Rebind();
}
#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);
}
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.RadioButton1.CheckedChanged += new System.EventHandler(this.RadioCheckedChanged);
this.RadioButton2.CheckedChanged += new System.EventHandler(this.RadioCheckedChanged);
this.RadGrid1.NeedDataSource += new Telerik.WebControls.GridNeedDataSourceEventHandler(this.RadGrid1_NeedDataSource);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -