зеркало из
1
0
Форкнуть 0
This commit is contained in:
Attila Antal 2024-11-08 17:16:23 +02:00
Родитель 46d59958ea
Коммит 8d250155b4
Не найден ключ, соответствующий данной подписи
19 изменённых файлов: 1416 добавлений и 1230 удалений

Просмотреть файл

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid BatchEditing CRUD</Title>
<Author>Progress</Author>
<Shortcut>gridsnippet</Shortcut>
<Description>Markup snippet for a RadGrid control with CRUD operations using the BatchEditing functionality.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
$end$
#region Datasource stored in Session
public DataTable SessionDataSource
{
get
{
string sessionKey = "SessionDataSource";
DataTable dt = Session[sessionKey] as DataTable;
if (dt == null || !IsPostBack)
{
dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(decimal)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 20; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = DateTime.Now.Date.AddDays(index);
row["Freight"] = index * 0.1 + index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
Session[sessionKey] = dt;
}
return dt;
}
}
#endregion
#region Data-binding
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = SessionDataSource;
}
#endregion
#region Insert/Update/Delete operations
protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
{
foreach (GridBatchEditingCommand command in e.Commands)
{
Hashtable oldValues = command.OldValues;
Hashtable newValues = command.NewValues;
if (command.Type == GridBatchEditingCommandType.Insert)
{
newValues["OrderID"] = CreateNewOrderId();
DataRow rowToCreate = SessionDataSource.NewRow();
foreach (string key in newValues.Keys)
{
rowToCreate[key] = newValues[key];
}
SessionDataSource.Rows.Add(rowToCreate);
}
else if (command.Type == GridBatchEditingCommandType.Update)
{
DataRow rowToUpdate = GetRowById((int) newValues["OrderID"]);
foreach (string key in newValues.Keys)
{
rowToUpdate[key] = newValues[key];
}
}
else if (command.Type == GridBatchEditingCommandType.Delete)
{
DataRow rowToDelete = GetRowById((int) newValues["OrderID"]);
if (rowToDelete != null)
{
SessionDataSource.Rows.Remove(rowToDelete);
}
}
}
}
#endregion
#region Helper Methods
private int CreateNewOrderId()
{
int orderId = 1;
if (SessionDataSource.Rows.Count > 0)
{
orderId = (int) SessionDataSource.Select("OrderID = MAX(OrderID)").FirstOrDefault()["OrderID"] + 1;
}
return orderId;
}
private DataRow GetRowById(int orderId)
{
return SessionDataSource.Select(string.Format("OrderID='{0}'", orderId)).FirstOrDefault();
}
#endregion
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Collections</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>System.Linq</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,78 +1,80 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Excel-Like Filtering</Title>
<Shortcut>radgridexcel</Shortcut>
<Description>CSharp - code snippets for RadGrid events and datasources needed for Excel-Like filtering</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = OrdersTable();$end$
}
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(decimal)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 70; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddHours(index);
row["Freight"] = index * 0.1 + index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
protected void RadGrid1_FilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e)
{
string DataField = (e.Column as IGridDataColumn).GetActiveDataField();
e.ListBox.DataSource = OrdersTable().DefaultView.ToTable(true, DataField);
e.ListBox.DataKeyField = DataField;
e.ListBox.DataTextField = DataField;
e.ListBox.DataValueField = DataField;
e.ListBox.DataBind();
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Excel-Like Filtering</Title>
<Shortcut>gridsnippet</Shortcut>
<Description>CSharp - code snippets for RadGrid events and datasources needed for Excel-Like filtering</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
$end$
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = OrdersTable();$end$
}
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(decimal)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 70; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddHours(index);
row["Freight"] = index * 0.1 + index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
protected void RadGrid1_FilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e)
{
string DataField = (e.Column as IGridDataColumn).GetActiveDataField();
e.ListBox.DataSource = OrdersTable().DefaultView.ToTable(true, DataField);
e.ListBox.DataKeyField = DataField;
e.ListBox.DataTextField = DataField;
e.ListBox.DataValueField = DataField;
e.ListBox.DataBind();
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,112 +1,114 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid with 2 level Hierarchy with NeedDataSource</Title>
<Author>Progress</Author>
<Shortcut>radgridhierarchy</Shortcut>
<Description>Markup snippet for a RadGrid control with a 2 level Hierarchy using the NeedDataSource event.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = OrdersTable();
}
protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
if (e.DetailTableView.Name == "OrderDetails")
{
GridDataItem parentItem = e.DetailTableView.ParentItem;
int orderId = (int)parentItem.GetDataKeyValue("OrderID");
e.DetailTableView.DataSource = OrderDetailsTable().Select(string.Format("OrderID = '{0}'", orderId));
}
}
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(double)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 100; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = DateTime.Now.Date.AddDays(index);
row["Freight"] = index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
private DataTable OrderDetailsTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("UnitPrice", typeof(decimal)));
dt.Columns.Add(new DataColumn("Quantity", typeof(int)));
dt.Columns.Add(new DataColumn("Discount", typeof(decimal)));
var orders = OrdersTable();
int itemsPerOrder = 4;
for (int rowIndex = 0; rowIndex < orders.Rows.Count; rowIndex++)
{
DataRow currentOrder = orders.Rows[rowIndex];
for (int j = 0; j < itemsPerOrder; j++)
{
int index = j + 1;
DataRow row = dt.NewRow();
row["OrderID"] = currentOrder["OrderID"];
row["UnitPrice"] = index;
row["Quantity"] = index;
row["Discount"] = index * 0.01;
dt.Rows.Add(row);
}
}
return dt;
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid with 2 level Hierarchy with NeedDataSource</Title>
<Author>Progress</Author>
<Shortcut>gridsnippet</Shortcut>
<Description>Markup snippet for a RadGrid control with a 2 level Hierarchy using the NeedDataSource event.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
$end$
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = OrdersTable();
}
protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
if (e.DetailTableView.Name == "OrderDetails")
{
GridDataItem parentItem = e.DetailTableView.ParentItem;
int orderId = (int)parentItem.GetDataKeyValue("OrderID");
e.DetailTableView.DataSource = OrderDetailsTable().Select(string.Format("OrderID = '{0}'", orderId));
}
}
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(double)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 100; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = DateTime.Now.Date.AddDays(index);
row["Freight"] = index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
private DataTable OrderDetailsTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("UnitPrice", typeof(decimal)));
dt.Columns.Add(new DataColumn("Quantity", typeof(int)));
dt.Columns.Add(new DataColumn("Discount", typeof(decimal)));
var orders = OrdersTable();
int itemsPerOrder = 4;
for (int rowIndex = 0; rowIndex < orders.Rows.Count; rowIndex++)
{
DataRow currentOrder = orders.Rows[rowIndex];
for (int j = 0; j < itemsPerOrder; j++)
{
int index = j + 1;
DataRow row = dt.NewRow();
row["OrderID"] = currentOrder["OrderID"];
row["UnitPrice"] = index;
row["Quantity"] = index;
row["Discount"] = index * 0.01;
dt.Rows.Add(row);
}
}
return dt;
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,183 +1,184 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Manual CRUD</Title>
<Shortcut>radgridmanualcrud</Shortcut>
<Description>CSharp code snippets for RadGrid Manual CRUD operations using Advanced DataBinding with NeedDataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
$end$
#region Properties for CRUD Operations
public DataTable SessionDataSource
{
get
{
string sessionKey = "SessionDataSource";
if (Session[sessionKey] == null || !IsPostBack)
{
Session[sessionKey] = OrdersTable();
}
return (DataTable)Session[sessionKey];
}
}
#endregion
#region RadGrid Events for CRUD Operations
// CREATE (Add New Record)
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
DataRow newRow = SessionDataSource.NewRow();
//As this example demonstrates only in-memory editing, a new primary key value should be generated
//This should not be applied when updating directly the database
DataRow[] allValues = SessionDataSource.Select("OrderID = MAX(OrderID)");
if (allValues.Length > 0)
{
newRow["OrderID"] = int.Parse(allValues[0]["OrderID"].ToString()) + 1;
}
else
{
newRow["OrderID"] = 1; //the table is empty;
}
//Set new values
Hashtable newValues = new Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
try
{
foreach (DictionaryEntry entry in newValues)
{
newRow[(string)entry.Key] = entry.Value;
}
}
catch (Exception ex)
{
Label1.Text += string.Format("<br />Unable to insert into Orders. Reason: {0}", ex.Message);
e.Canceled = true;
return;
}
SessionDataSource.Rows.Add(newRow);
//Code for updating the database ca go here...
Label1.Text += string.Format("<br />Order {0} inserted", newRow["OrderID"]);
}
// READ (data binding)
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = SessionDataSource;
}
// UPDATE
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
//Locate the changed row in the DataSource
DataRow[] changedRows = SessionDataSource.Select(string.Format("OrderID = {0}", editedItem.GetDataKeyValue("OrderID")));
if (changedRows.Length != 1)
{
this.Label1.Text += "Unable to locate the Order for updating.";
e.Canceled = true;
return;
}
//Update new values
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
changedRows[0].BeginEdit();
try
{
foreach (DictionaryEntry entry in newValues)
{
changedRows[0][(string)entry.Key] = entry.Value;
}
changedRows[0].EndEdit();
}
catch (Exception ex)
{
changedRows[0].CancelEdit();
Label1.Text += string.Format("Unable to update Orders. Reason: {0}", ex.Message);
e.Canceled = true;
return;
}
}
// DELETE
protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
{
GridDataItem dataItem = e.Item as GridDataItem;
string ID = dataItem.GetDataKeyValue("OrderID").ToString();
if (SessionDataSource.Rows.Find(ID) != null)
{
SessionDataSource.Rows.Find(ID).Delete();
}
}
#endregion
#region DataSource
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(decimal)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 70; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddHours(index);
row["Freight"] = index * 0.1 + index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
#endregion
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Collections</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Manual CRUD</Title>
<Shortcut>gridsnippet</Shortcut>
<Description>CSharp code snippets for RadGrid Manual CRUD operations using Advanced DataBinding with NeedDataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
$end$
#region Properties for CRUD Operations
public DataTable SessionDataSource
{
get
{
string sessionKey = "SessionDataSource";
if (Session[sessionKey] == null || !IsPostBack)
{
Session[sessionKey] = OrdersTable();
}
return (DataTable)Session[sessionKey];
}
}
#endregion
#region RadGrid Events for CRUD Operations
// CREATE (Add New Record)
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
DataRow newRow = SessionDataSource.NewRow();
//As this example demonstrates only in-memory editing, a new primary key value should be generated
//This should not be applied when updating directly the database
DataRow[] allValues = SessionDataSource.Select("OrderID = MAX(OrderID)");
if (allValues.Length > 0)
{
newRow["OrderID"] = int.Parse(allValues[0]["OrderID"].ToString()) + 1;
}
else
{
newRow["OrderID"] = 1; //the table is empty;
}
//Set new values
Hashtable newValues = new Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
try
{
foreach (DictionaryEntry entry in newValues)
{
newRow[(string)entry.Key] = entry.Value;
}
}
catch (Exception ex)
{
Label1.Text += string.Format("<br />Unable to insert into Orders. Reason: {0}", ex.Message);
e.Canceled = true;
return;
}
SessionDataSource.Rows.Add(newRow);
//Code for updating the database ca go here...
Label1.Text += string.Format("<br />Order {0} inserted", newRow["OrderID"]);
}
// READ (data binding)
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = SessionDataSource;
}
// UPDATE
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
//Locate the changed row in the DataSource
DataRow[] changedRows = SessionDataSource.Select(string.Format("OrderID = {0}", editedItem.GetDataKeyValue("OrderID")));
if (changedRows.Length != 1)
{
this.Label1.Text += "Unable to locate the Order for updating.";
e.Canceled = true;
return;
}
//Update new values
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
changedRows[0].BeginEdit();
try
{
foreach (DictionaryEntry entry in newValues)
{
changedRows[0][(string)entry.Key] = entry.Value;
}
changedRows[0].EndEdit();
}
catch (Exception ex)
{
changedRows[0].CancelEdit();
Label1.Text += string.Format("Unable to update Orders. Reason: {0}", ex.Message);
e.Canceled = true;
return;
}
}
// DELETE
protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
{
GridDataItem dataItem = e.Item as GridDataItem;
string ID = dataItem.GetDataKeyValue("OrderID").ToString();
if (SessionDataSource.Rows.Find(ID) != null)
{
SessionDataSource.Rows.Find(ID).Delete();
}
}
#endregion
#region DataSource
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(decimal)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 70; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddHours(index);
row["Freight"] = index * 0.1 + index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
#endregion
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Collections</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,65 +1,67 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid NeedDataSource</Title>
<Shortcut>radgridneed</Shortcut>
<Description>CSharp code snippets for RadGrid with Advanced DataBinding using NeedDataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = OrdersTable(); $end$
}
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(double)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 100; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = DateTime.Now.Date.AddDays(index);
row["Freight"] = index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid NeedDataSource</Title>
<Shortcut>gridsnippet</Shortcut>
<Description>CSharp code snippets for RadGrid with Advanced DataBinding using NeedDataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
$end$
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
(sender as RadGrid).DataSource = OrdersTable(); $end$
}
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(double)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 100; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = DateTime.Now.Date.AddDays(index);
row["Freight"] = index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,208 +1,183 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Self Data Source</Title>
<Shortcut>radgridselfdatasource</Shortcut>
<Description>CSharp code snippet for Generating a DataSource based on the Grid's Markup definition</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
var grid = (RadGrid)sender;
grid.DataSource = GridSelfDataSource(grid); $end$
}
private DataTable GridSelfDataSource(RadGrid grid, int recordsCount = 100)
{
if (!grid.AllowPaging) recordsCount = 20;
var dt = new DataTable();
// Access the DataKeyNames collection of the MasterTable
var dataKeyNames = grid.MasterTableView.DataKeyNames;
// Loop through the DataKeyNames
foreach (string dataKeyName in dataKeyNames)
{
dt.Columns.Add(new DataColumn(dataKeyName, typeof(int)));
}
if (dataKeyNames.Length > 0)
dt.PrimaryKey = new DataColumn[] { dt.Columns[dataKeyNames[0]] };
IEnumerable<IGridDataColumn> dataColumns = grid.MasterTableView.RenderColumns.OfType<IGridDataColumn>();
// First Loop through all GridBoundColumns.
foreach (GridBoundColumn boundCol in dataColumns.Where(col => col.GetType().Name == "GridBoundColumn").Select(col => col as GridBoundColumn))
{
// Ignore the column if has no DataField property defined
if (string.IsNullOrEmpty(boundCol.DataField)) continue;
// Assume String Type
Type dataType = boundCol.DataType;
if (boundCol.Aggregate != GridAggregateFunction.None)
{
// If Column has no DataType specified but Aggregates
switch (boundCol.Aggregate)
{
case GridAggregateFunction.Sum:
case GridAggregateFunction.Min:
case GridAggregateFunction.Max:
case GridAggregateFunction.Avg:
// For aggregates like Sum, Min, Max, Avg change the type to double
dataType = typeof(double);
break;
}
}
if (dataKeyNames.Contains(boundCol.DataField))
{
if (dataType != typeof(string))
{
dt.Columns[boundCol.DataField].DataType = dataType;
}
}
else if (dt.Columns.IndexOf(boundCol.DataField) < 0)
{
dt.Columns.Add(boundCol.DataField, dataType);
}
}
// Loop through the rest of the columns
foreach (IGridDataColumn gridCol in dataColumns.Where(col => col.GetType().Name != "GridBoundColumn"))
{
string activeDataField = gridCol.GetActiveDataField();
if (string.IsNullOrEmpty(activeDataField) || dt.Columns.IndexOf(activeDataField) > -1) continue;
GridNumericColumn numericCol = gridCol as GridNumericColumn;
if (numericCol != null)
{
dt.Columns.Add(numericCol.DataField, typeof(int));
}
GridDateTimeColumn dateTimeCol = gridCol as GridDateTimeColumn;
if (dateTimeCol != null)
{
dt.Columns.Add(dateTimeCol.DataField, typeof(DateTime));
}
GridTemplateColumn templateCol = gridCol as GridTemplateColumn;
if (templateCol != null)
{
dt.Columns.Add(templateCol.DataField, templateCol.DataType);
}
GridHyperLinkColumn hyperLinkCol = gridCol as GridHyperLinkColumn;
if (hyperLinkCol != null)
{
if (!string.IsNullOrEmpty(hyperLinkCol.DataTextField) && dt.Columns.IndexOf(hyperLinkCol.DataTextField) < 0)
dt.Columns.Add(hyperLinkCol.DataTextField, hyperLinkCol.DataType);
foreach (string navUrl in hyperLinkCol.DataNavigateUrlFields)
{
if (dt.Columns.IndexOf(navUrl) >= 0) continue;
dt.Columns.Add(navUrl, hyperLinkCol.DataType);
}
}
GridDropDownColumn dropDownCol = gridCol as GridDropDownColumn;
if (dropDownCol != null)
{
if (!string.IsNullOrEmpty(dropDownCol.DataField) && dt.Columns.IndexOf(dropDownCol.DataField) < 0)
dt.Columns.Add(dropDownCol.DataField, dropDownCol.DataType);
if (!string.IsNullOrEmpty(dropDownCol.ListTextField) && dt.Columns.IndexOf(dropDownCol.ListTextField) < 0)
dt.Columns.Add(dropDownCol.ListTextField, dropDownCol.DataType);
if (!string.IsNullOrEmpty(dropDownCol.ListValueField) && dt.Columns.IndexOf(dropDownCol.ListValueField) < 0)
dt.Columns.Add(dropDownCol.ListValueField, dropDownCol.DataType);
if (!string.IsNullOrEmpty(dropDownCol.ListDataMember) && dt.Columns.IndexOf(dropDownCol.ListDataMember) < 0)
dt.Columns.Add(dropDownCol.ListDataMember, dropDownCol.DataType);
}
GridAutoCompleteColumn autoCompleteCol = gridCol as GridAutoCompleteColumn;
if (autoCompleteCol != null)
{
if (!string.IsNullOrEmpty(autoCompleteCol.DataField) && dt.Columns.IndexOf(autoCompleteCol.DataField) < 0)
dt.Columns.Add(autoCompleteCol.DataField, autoCompleteCol.DataType);
}
GridAttachmentColumn attachmentCol = gridCol as GridAttachmentColumn;
if (attachmentCol != null)
{
if (!string.IsNullOrEmpty(attachmentCol.DataTextField) && dt.Columns.IndexOf(attachmentCol.DataTextField) < 0)
dt.Columns.Add(attachmentCol.DataTextField, attachmentCol.DataType);
}
GridCalculatedColumn calculatedCol = gridCol as GridCalculatedColumn;
if (calculatedCol != null)
{
foreach (string field in calculatedCol.DataFields)
{
if (dt.Columns.IndexOf(field) < 0)
dt.Columns.Add(field, typeof(int));
}
}
}
for (int i = 0; i <= recordsCount; i++)
{
DataRow row = dt.NewRow();
foreach (DataColumn col in dt.Columns)
{
if (col.DataType == typeof(int))
{
row[col.ColumnName] = i + 1;
}
else if (col.DataType == typeof(string))
{
row[col.ColumnName] = col.ColumnName + i;
}
else if (col.DataType == typeof(DateTime))
{
row[col.ColumnName] = DateTime.Now.Date.AddDays(i);
}
else if (col.DataType == typeof(decimal) || col.DataType == typeof(double) || col.DataType == typeof(float))
{
row[col.ColumnName] = i * 0.1;
}
}
dt.Rows.Add(row);
}
return dt;
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>System.Linq</Namespace>
</Import>
<Import>
<Namespace>System.Collections.Generic</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Self Data Source</Title>
<Shortcut>gridsnippet</Shortcut>
<Description>CSharp code snippet for Generating a DataSource based on the Grid's Markup definition</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[$end$
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
RadGrid grid = (RadGrid) sender;
grid.DataSource = GridSelfDataSource(grid);
}
#region Data Source Generator for RadGrid
private DataTable GridSelfDataSource(RadGrid grid, int recordsCount = 20)
{
var dt = new DataTable();
foreach (string dataKeyName in grid.MasterTableView.DataKeyNames)
{
dt.Columns.Add(dataKeyName, typeof(int));
}
foreach (IGridDataColumn gridDataCol in grid.MasterTableView.RenderColumns.Where(col => col is IGridDataColumn))
{
string dataField = gridDataCol.GetActiveDataField();
if (string.IsNullOrEmpty(dataField)) continue;
Type dataType = GetColumnDataType(gridDataCol);
if (gridDataCol.GetType().Name == "GridHyperLinkColumn")
{
GridHyperLinkColumn hyperLinkCol = (GridHyperLinkColumn) gridDataCol;
AddColumnToTable(dt, hyperLinkCol.DataTextField, typeof(string));
foreach (string fieldName in hyperLinkCol.DataNavigateUrlFields)
{
AddColumnToTable(dt, fieldName, typeof(string));
}
}
else if (gridDataCol.GetType().Name == "GridDropDownColumn")
{
GridDropDownColumn dropDownCol = (GridDropDownColumn) gridDataCol;
AddColumnToTable(dt, dropDownCol.ListTextField, typeof(string));
AddColumnToTable(dt, dropDownCol.ListValueField, typeof(string));
}
if (gridDataCol.GetType().Name == "GridAutoCompleteColumn")
{
GridAutoCompleteColumn autoCompleteCol = (GridAutoCompleteColumn) gridDataCol;
AddColumnToTable(dt, autoCompleteCol.DataTextField, typeof(string));
AddColumnToTable(dt, autoCompleteCol.DataValueField, typeof(string));
}
if (gridDataCol.GetType().Name == "GridAttachmentColumn")
{
GridAttachmentColumn attachmentCol = (GridAttachmentColumn) gridDataCol;
AddColumnToTable(dt, attachmentCol.DataTextField, typeof(string));
AddColumnToTable(dt, attachmentCol.AttachmentDataField, typeof(string));
}
if (gridDataCol.GetType().Name == "GridCalculatedColumn")
{
GridDropDownColumn dropDownCol = (GridDropDownColumn) gridDataCol;
AddColumnToTable(dt, dropDownCol.ListTextField, typeof(string));
}
else
{
AddColumnToTable(dt, dataField, dataType);
}
}
for (int i = 0; i <= recordsCount; i++)
{
DataRow row = dt.NewRow();
foreach (DataColumn col in dt.Columns)
{
if (col.DataType == typeof(int))
{
row[col.ColumnName] = i + 1;
}
else if (col.DataType == typeof(string))
{
row[col.ColumnName] = col.ColumnName + i;
}
else if (col.DataType == typeof(DateTime))
{
row[col.ColumnName] = DateTime.Now.Date.AddDays(i);
}
else if (col.DataType == typeof(decimal) || col.DataType == typeof(double) || col.DataType == typeof(float))
{
row[col.ColumnName] = i * 0.1;
}
else if (col.DataType == typeof(bool))
{
row[col.ColumnName] = i % 3 == 0;
}
}
dt.Rows.Add(row);
}
return dt;
}
private Type GetColumnDataType(IGridDataColumn col)
{
// Aggregates for Numeric values only
int[] aggregateTypes = new int[] { (int) GridAggregateFunction.Sum, (int) GridAggregateFunction.Min, (int) GridAggregateFunction.Max, (int) GridAggregateFunction.Avg };
Type dataType = ((GridColumn) col).DataType;
switch (col.GetType().Name)
{
case "GridBoundColumn":
GridBoundColumn boundCol = (GridBoundColumn) col;
if (aggregateTypes.Contains((int) boundCol.Aggregate)) dataType = typeof(decimal);
break;
case "GridNumericColumn":
GridNumericColumn numericCol = (GridNumericColumn) col;
if (aggregateTypes.Contains((int) numericCol.Aggregate)) dataType = typeof(decimal);
break;
case "GridDateTimeColumn":
GridDateTimeColumn dateTimeCol = (GridDateTimeColumn) col;
if (aggregateTypes.Contains((int) dateTimeCol.Aggregate)) dataType = typeof(DateTime);
break;
case "GridTemplateColumns":
GridTemplateColumn templateCol = (GridTemplateColumn) col;
if (aggregateTypes.Contains((int) templateCol.Aggregate)) dataType = typeof(decimal);
break;
case "GridCheckBoxColumn":
dataType = typeof(bool);
break;
}
return dataType;
}
private void AddColumnToTable(DataTable dt, string columnName, Type dataType)
{
if (dt.Columns.IndexOf(columnName) > -1)
{
if (dataType != typeof(string))
{
dt.Columns[columnName].DataType = dataType;
}
}
else
{
dt.Columns.Add(columnName, dataType);
}
}
#endregion
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>System.Linq</Namespace>
</Import>
<Import>
<Namespace>System.Collections.Generic</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,89 +1,91 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Programmatic with SqlDataSource</Title>
<Shortcut>radgridsqlprog</Shortcut>
<Description>CSharp code snippets for programmatically created RadGrid with declarative DataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
protected void Page_Init(object sender, System.EventArgs e)
{
DefineGridStructure();
}
private void DefineGridStructure()
{
RadGrid grid = new RadGrid();
grid.ID = "RadGrid1";
grid.DataSourceID = "SqlDataSource1";
grid.AllowAutomaticInserts = true;
grid.AllowAutomaticUpdates = true;
grid.AllowAutomaticDeletes = true;
grid.AutoGenerateEditColumn = true;
grid.AutoGenerateDeleteColumn = true;
grid.Skin = "Vista";
grid.Width = Unit.Percentage(100);
grid.PageSize = 15;
grid.AllowPaging = true;
grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
grid.AutoGenerateColumns = false;
grid.MasterTableView.Width = Unit.Percentage(100);
grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
grid.MasterTableView.DataKeyNames = new string[] { "OrderID" };
GridNumericColumn numericColumn = new GridNumericColumn();
numericColumn.DataField = "OrderID";
numericColumn.HeaderText = "Order ID";
grid.MasterTableView.Columns.Add(numericColumn);
numericColumn = new GridNumericColumn();
numericColumn.DataField = "Freight";
numericColumn.HeaderText = "Freight";
grid.MasterTableView.Columns.Add(numericColumn);
GridDateTimeColumn dateTimeColumn = new GridDateTimeColumn();
dateTimeColumn.DataField = "OrderDate";
dateTimeColumn.HeaderText = "OrderDate";
grid.MasterTableView.Columns.Add(dateTimeColumn);
GridBoundColumn boundColumn = new GridBoundColumn();
boundColumn.DataField = "ShipName";
boundColumn.HeaderText = "Ship Name";
grid.MasterTableView.Columns.Add(boundColumn);
boundColumn = new GridBoundColumn();
boundColumn.DataField = "ShipCountry";
boundColumn.HeaderText = "Ship Country";
grid.MasterTableView.Columns.Add(boundColumn);
// Add the grid to the placeholder
this.PlaceHolder1.Controls.Add(grid);
}$end$
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Programmatic with SqlDataSource</Title>
<Shortcut>gridsnippet</Shortcut>
<Description>CSharp code snippets for programmatically created RadGrid with declarative DataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
$end$
protected void Page_Init(object sender, System.EventArgs e)
{
DefineGridStructure();
}
private void DefineGridStructure()
{
RadGrid grid = new RadGrid();
grid.ID = "RadGrid1";
grid.DataSourceID = "SqlDataSource1";
grid.AllowAutomaticInserts = true;
grid.AllowAutomaticUpdates = true;
grid.AllowAutomaticDeletes = true;
grid.AutoGenerateEditColumn = true;
grid.AutoGenerateDeleteColumn = true;
grid.Skin = "Vista";
grid.Width = Unit.Percentage(100);
grid.PageSize = 15;
grid.AllowPaging = true;
grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
grid.AutoGenerateColumns = false;
grid.MasterTableView.Width = Unit.Percentage(100);
grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
grid.MasterTableView.DataKeyNames = new string[] { "OrderID" };
GridNumericColumn numericColumn = new GridNumericColumn();
numericColumn.DataField = "OrderID";
numericColumn.HeaderText = "Order ID";
grid.MasterTableView.Columns.Add(numericColumn);
numericColumn = new GridNumericColumn();
numericColumn.DataField = "Freight";
numericColumn.HeaderText = "Freight";
grid.MasterTableView.Columns.Add(numericColumn);
GridDateTimeColumn dateTimeColumn = new GridDateTimeColumn();
dateTimeColumn.DataField = "OrderDate";
dateTimeColumn.HeaderText = "OrderDate";
grid.MasterTableView.Columns.Add(dateTimeColumn);
GridBoundColumn boundColumn = new GridBoundColumn();
boundColumn.DataField = "ShipName";
boundColumn.HeaderText = "Ship Name";
grid.MasterTableView.Columns.Add(boundColumn);
boundColumn = new GridBoundColumn();
boundColumn.DataField = "ShipCountry";
boundColumn.HeaderText = "Ship Country";
grid.MasterTableView.Columns.Add(boundColumn);
// Add the grid to the placeholder
this.PlaceHolder1.Controls.Add(grid);
}$end$
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,92 +1,94 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadPivotGrid Self Data Source</Title>
<Shortcut>radpivotgridselfdatasource</Shortcut>
<Description>CSharp code snippet for Generating a DataSource based on the PivotGrid's Markup definition</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
protected void RadPivotGrid1_NeedDataSource(object sender, PivotGridNeedDataSourceEventArgs e)
{
var pivotGrid = (RadPivotGrid)sender;
pivotGrid.DataSource = PivotGridSelfDataSource(pivotGrid);
}
private DataTable PivotGridSelfDataSource(RadPivotGrid pivotGrid, int recordsCount = 100)
{
if (!pivotGrid.AllowPaging) recordsCount = 10;
DataTable dt = new DataTable();
foreach (PivotGridField field in pivotGrid.Fields)
{
string dataField = field.DataField;
Type type = typeof(string);
if (field is PivotGridAggregateField)
{
var aggregateField = (PivotGridAggregateField)field;
if (aggregateField.Aggregate != PivotGridAggregate.Count)
{
type = typeof(double);
}
}
if (dt.Columns.IndexOf(dataField) > -1) continue;
dt.Columns.Add(new DataColumn(dataField, type));
}
for (int i = 0; i <= recordsCount; i++)
{
DataRow row = dt.NewRow();
foreach (DataColumn col in dt.Columns)
{
if (col.DataType == typeof(int))
{
row[col.ColumnName] = i + 1;
}
else if (col.DataType == typeof(string))
{
row[col.ColumnName] = col.ColumnName + i;
}
else if (col.DataType == typeof(DateTime))
{
row[col.ColumnName] = DateTime.Now.Date.AddDays(i);
}
else if (col.DataType == typeof(decimal) || col.DataType == typeof(double) || col.DataType == typeof(float))
{
row[col.ColumnName] = i * 0.1;
}
}
dt.Rows.Add(row);
}
return dt;
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadPivotGrid Self Data Source</Title>
<Shortcut>pivotgridsnippet</Shortcut>
<Description>CSharp code snippet for Generating a DataSource based on the PivotGrid's Markup definition</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[
$end$
protected void RadPivotGrid1_NeedDataSource(object sender, PivotGridNeedDataSourceEventArgs e)
{
var pivotGrid = (RadPivotGrid)sender;
pivotGrid.DataSource = PivotGridSelfDataSource(pivotGrid);
}
private DataTable PivotGridSelfDataSource(RadPivotGrid pivotGrid, int recordsCount = 100)
{
if (!pivotGrid.AllowPaging) recordsCount = 10;
DataTable dt = new DataTable();
foreach (PivotGridField field in pivotGrid.Fields)
{
string dataField = field.DataField;
Type type = typeof(string);
if (field is PivotGridAggregateField)
{
var aggregateField = (PivotGridAggregateField)field;
if (aggregateField.Aggregate != PivotGridAggregate.Count)
{
type = typeof(double);
}
}
if (dt.Columns.IndexOf(dataField) > -1) continue;
dt.Columns.Add(new DataColumn(dataField, type));
}
for (int i = 0; i <= recordsCount; i++)
{
DataRow row = dt.NewRow();
foreach (DataColumn col in dt.Columns)
{
if (col.DataType == typeof(int))
{
row[col.ColumnName] = i + 1;
}
else if (col.DataType == typeof(string))
{
row[col.ColumnName] = col.ColumnName + i;
}
else if (col.DataType == typeof(DateTime))
{
row[col.ColumnName] = DateTime.Now.Date.AddDays(i);
}
else if (col.DataType == typeof(decimal) || col.DataType == typeof(double) || col.DataType == typeof(float))
{
row[col.ColumnName] = i * 0.1;
}
}
dt.Rows.Add(row);
}
return dt;
}
]]>
</Code>
<Imports>
<Import>
<Namespace>System</Namespace>
</Import>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>Telerik.Web.UI</Namespace>
</Import>
</Imports>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Debug ScriptManager</Title>
<Author>Peter Milchev</Author>
<Shortcut>debugsm</Shortcut>
<Description>Code snippets for DebugScriptManager and RadAjaxManager markup</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="html"><![CDATA[<%@ Register Namespace="Telerik.Web.UI.Debug" TagPrefix="debug" %>
<debug:DebugScriptManager runat="server" ID="DebugScriptManager1"
StartPath="http://pmilchev.bedford.progress.com/DevDSM/">
</debug:DebugScriptManager>
$end$]]></Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Debug ScriptManager</Title>
<Author>Progress</Author>
<Shortcut>debugsm</Shortcut>
<Description>Code snippet for Debug ScriptManager used in development</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="html"><![CDATA[
<%@ Register Namespace="Telerik.Web.UI.Debug" TagPrefix="debug" %>
<debug:DebugScriptManager runat="server" ID="DebugScriptManager1" ProjectUrl="https://localhost/Telerik.Web.UI/" EnableDebugOutput="true">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</debug:DebugScriptManager>
$end$]]></Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -1,24 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadScriptManager with jQuery ScriptReferences</Title>
<Author>Progress</Author>
<Shortcut>init</Shortcut>
<Description>Code snippet for RadScriptManager</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="html"><![CDATA[
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>
$end$
]]></Code>
</Snippet>
</CodeSnippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadScriptManager with jQuery ScriptReferences</Title>
<Author>Progress</Author>
<Shortcut>init</Shortcut>
<Description>Code snippet for RadScriptManager</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="html"><![CDATA[
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>
$end$
]]></Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -1,76 +1,76 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid Automatic CRUD Operations</Title>
<Author>Progress</Author>
<Shortcut>radgridautomaticcrud</Shortcut>
<Description>Markup snippet for a RadGrid Automatic CRUD operations with declarative binding using DataSourceID</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML" Delimiter="^">
<![CDATA[
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px"
AutoGenerateEditColumn="true"
AutoGenerateDeleteColumn="true"
DataSourceID="SqlDataSource1"
AllowAutomaticInserts="true"
AllowAutomaticUpdates="true"
AllowAutomaticDeletes="true">
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False" CommandItemDisplay="Top"
DataKeyNames="OrderID" ^end^>
<Columns>
<telerik:GridNumericColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridNumericColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
InsertCommand="INSERT INTO [Orders] ([OrderDate], [Freight], [ShipName], [ShipCountry]) VALUES (@OrderDate, @Freight, @ShipName, @ShipCountry)"
SelectCommand="SELECT [OrderID], [OrderDate], [Freight], [ShipName], [ShipCountry] FROM [Orders]"
UpdateCommand="UPDATE [Orders] SET [OrderDate] = @OrderDate, [Freight] = @Freight, [ShipName] = @ShipName, [ShipCountry] = @ShipCountry WHERE [OrderID] = @OrderID"
DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID">
<InsertParameters>
<asp:Parameter Name="OrderDate" DbType="DateTime" />
<asp:Parameter Name="Freight" DbType="Decimal" />
<asp:Parameter Name="ShipName" DbType="String" />
<asp:Parameter Name="ShipCountry" DbType="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="OrderID" DbType="Int32" />
<asp:Parameter Name="OrderDate" DbType="DateTime" />
<asp:Parameter Name="Freight" DbType="Decimal" />
<asp:Parameter Name="ShipName" DbType="String" />
<asp:Parameter Name="ShipCountry" DbType="String" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="OrderID" DbType="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
]]>
</Code>
</Snippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid Automatic CRUD Operations</Title>
<Author>Progress</Author>
<Shortcut>radgridautomaticcrud</Shortcut>
<Description>Markup snippet for a RadGrid Automatic CRUD operations with declarative binding using DataSourceID</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML" Delimiter="^">
<![CDATA[
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px"
AutoGenerateEditColumn="true"
AutoGenerateDeleteColumn="true"
DataSourceID="SqlDataSource1"
AllowAutomaticInserts="true"
AllowAutomaticUpdates="true"
AllowAutomaticDeletes="true">
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False" CommandItemDisplay="Top"
DataKeyNames="OrderID" ^end^>
<Columns>
<telerik:GridNumericColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridNumericColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
InsertCommand="INSERT INTO [Orders] ([OrderDate], [Freight], [ShipName], [ShipCountry]) VALUES (@OrderDate, @Freight, @ShipName, @ShipCountry)"
SelectCommand="SELECT [OrderID], [OrderDate], [Freight], [ShipName], [ShipCountry] FROM [Orders]"
UpdateCommand="UPDATE [Orders] SET [OrderDate] = @OrderDate, [Freight] = @Freight, [ShipName] = @ShipName, [ShipCountry] = @ShipCountry WHERE [OrderID] = @OrderID"
DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID">
<InsertParameters>
<asp:Parameter Name="OrderDate" DbType="DateTime" />
<asp:Parameter Name="Freight" DbType="Decimal" />
<asp:Parameter Name="ShipName" DbType="String" />
<asp:Parameter Name="ShipCountry" DbType="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="OrderID" DbType="Int32" />
<asp:Parameter Name="OrderDate" DbType="DateTime" />
<asp:Parameter Name="Freight" DbType="Decimal" />
<asp:Parameter Name="ShipName" DbType="String" />
<asp:Parameter Name="ShipCountry" DbType="String" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="OrderID" DbType="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
]]>
</Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid CRUD with BatchEditing</Title>
<Author>Progress</Author>
<Shortcut>radgridbatcheditcrud</Shortcut>
<Description>Markup snippet for a RadGrid control with CRUD operations using the BatchEditing functionality.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource" OnBatchEditCommand="RadGrid1_BatchEditCommand">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" CommandItemDisplay="Top" EditMode="Batch">
<BatchEditingSettings HighlightDeletedRows="true" />
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
<telerik:GridClientDeleteColumn HeaderText="Delete"></telerik:GridClientDeleteColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -1,50 +1,50 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid with Excel-Like Filtering</Title>
<Author>Progress</Author>
<Shortcut>radgridexcel</Shortcut>
<Description>Markup snippet for a RadGrid with Excel-like filtering</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px"
AllowFilteringByColumn="true"
FilterType="HeaderContext"
EnableHeaderContextMenu="true"
EnableHeaderContextFilterMenu="true"
OnFilterCheckListItemsRequested="RadGrid1_FilterCheckListItemsRequested"
OnNeedDataSource="RadGrid1_NeedDataSource" $end$>
<MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID">
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" FilterCheckListEnableLoadOnDemand="true"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime" FilterCheckListEnableLoadOnDemand="true"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal" FilterCheckListEnableLoadOnDemand="true"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName" FilterCheckListEnableLoadOnDemand="true"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry" FilterCheckListEnableLoadOnDemand="true"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid with Excel-Like Filtering</Title>
<Author>Progress</Author>
<Shortcut>radgridexcel</Shortcut>
<Description>Markup snippet for a RadGrid with Excel-like filtering</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px"
AllowFilteringByColumn="true"
FilterType="HeaderContext"
EnableHeaderContextMenu="true"
EnableHeaderContextFilterMenu="true"
OnFilterCheckListItemsRequested="RadGrid1_FilterCheckListItemsRequested"
OnNeedDataSource="RadGrid1_NeedDataSource" $end$>
<MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID">
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" FilterCheckListEnableLoadOnDemand="true"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime" FilterCheckListEnableLoadOnDemand="true"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal" FilterCheckListEnableLoadOnDemand="true"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName" FilterCheckListEnableLoadOnDemand="true"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry" FilterCheckListEnableLoadOnDemand="true"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -1,71 +1,68 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid with 2 level Hierarchy with NeedDataSource</Title>
<Author>Progress</Author>
<Shortcut>radgridhierarchy</Shortcut>
<Description>Markup snippet for a RadGrid control with a 2 level Hierarchy using the NeedDataSource event.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
<MasterTableView Name="Orders" AutoGenerateColumns="False" DataKeyNames="OrderID">
<Columns>
<telerik:GridNumericColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridNumericColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView Name="OrderDetails" AutoGenerateColumns="false">
<Columns>
<telerik:GridNumericColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn DataField="UnitPrice" DataType="System.Decimal"
FilterControlAltText="Filter UnitPrice column" HeaderText="UnitPrice"
SortExpression="UnitPrice" UniqueName="UnitPrice">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn DataField="Quantity" DataType="System.Int32"
FilterControlAltText="Filter Quantity column" HeaderText="Quantity"
SortExpression="Quantity" UniqueName="Quantity">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn DataField="Discount" DataType="System.Decimal"
FilterControlAltText="Filter Discount column" HeaderText="Discount"
SortExpression="Discount" UniqueName="Discount">
</telerik:GridNumericColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
<ClientSettings>
<ClientEvents OnRowContextMenu="OnRowContextMenu" OnRowClick="OnRowClick" />
</ClientSettings>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid with 2 level Hierarchy with NeedDataSource</Title>
<Author>Progress</Author>
<Shortcut>radgridhierarchy</Shortcut>
<Description>Markup snippet for a RadGrid control with a 2 level Hierarchy using the NeedDataSource event.</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
<MasterTableView Name="Orders" AutoGenerateColumns="False" DataKeyNames="OrderID">
<Columns>
<telerik:GridNumericColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridNumericColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView Name="OrderDetails" AutoGenerateColumns="false">
<Columns>
<telerik:GridNumericColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn DataField="UnitPrice" DataType="System.Decimal"
FilterControlAltText="Filter UnitPrice column" HeaderText="UnitPrice"
SortExpression="UnitPrice" UniqueName="UnitPrice">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn DataField="Quantity" DataType="System.Int32"
FilterControlAltText="Filter Quantity column" HeaderText="Quantity"
SortExpression="Quantity" UniqueName="Quantity">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn DataField="Discount" DataType="System.Decimal"
FilterControlAltText="Filter Discount column" HeaderText="Discount"
SortExpression="Discount" UniqueName="Discount">
</telerik:GridNumericColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -1,54 +1,54 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Manual CRUD</Title>
<Shortcut>radgridmanualcrud</Shortcut>
<Description>HTML markup code snippets for RadGrid Manual CRUD operations using Advanced DataBinding with NeedDataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[
<asp:Label ID="Label1" runat="server" Text="Action:"></asp:Label>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px"
AutoGenerateEditColumn="true"
AutoGenerateDeleteColumn="true"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnInsertCommand="RadGrid1_InsertCommand"
OnUpdateCommand="RadGrid1_UpdateCommand"
OnDeleteCommand="RadGrid1_DeleteCommand" $end$>
<MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" CommandItemDisplay="Top" InsertItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnLastPage">
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
</CodeSnippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>RadGrid Manual CRUD</Title>
<Shortcut>radgridmanualcrud</Shortcut>
<Description>HTML markup code snippets for RadGrid Manual CRUD operations using Advanced DataBinding with NeedDataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[
<asp:Label ID="Label1" runat="server" Text="Action:"></asp:Label>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px"
AutoGenerateEditColumn="true"
AutoGenerateDeleteColumn="true"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnInsertCommand="RadGrid1_InsertCommand"
OnUpdateCommand="RadGrid1_UpdateCommand"
OnDeleteCommand="RadGrid1_DeleteCommand" $end$>
<MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" CommandItemDisplay="Top" InsertItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnLastPage">
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Просмотреть файл

@ -1,44 +1,44 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid NeedDataSource</Title>
<Shortcut>radgridneed</Shortcut>
<Description>CSharp code snippets for RadGrid with Advanced DataBinding using NeedDataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource" $end$>
<MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID">
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid NeedDataSource</Title>
<Shortcut>radgridneed</Shortcut>
<Description>CSharp code snippets for RadGrid with Advanced DataBinding using NeedDataSource</Description>
<Author>Progress</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML">
<![CDATA[$end$
<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="true" AllowPaging="True" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource" AllowFilteringByColumn="true">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID">
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime" FilterControlWidth="160px"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate" DataFormatString="{0: MM/dd/yyyy}"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
]]>
</Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -1,49 +1,49 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid with SqlDataSource</Title>
<Author>Progress</Author>
<Shortcut>radgridsql</Shortcut>
<Description>Markup snippet for a RadGrid control with declarative binding using DataSourceID</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML" Delimiter="^">
<![CDATA[
<telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" DataSourceID="SqlDataSource1" Width="800px">
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False"
DataKeyNames="OrderID">
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString^end^ %>"
SelectCommand="SELECT [OrderID], [OrderDate], [Freight], [ShipName], [ShipCountry] FROM [Orders]"></asp:SqlDataSource>
]]>
</Code>
</Snippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid with SqlDataSource</Title>
<Author>Progress</Author>
<Shortcut>radgridsql</Shortcut>
<Description>Markup snippet for a RadGrid control with declarative binding using DataSourceID</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML" Delimiter="^">
<![CDATA[
<telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" DataSourceID="SqlDataSource1" Width="800px">
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False"
DataKeyNames="OrderID">
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString^end^ %>"
SelectCommand="SELECT [OrderID], [OrderDate], [Freight], [ShipName], [ShipCountry] FROM [Orders]"></asp:SqlDataSource>
]]>
</Code>
</Snippet>
</CodeSnippet>

Просмотреть файл

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid created Programmatically with SqlDataSource</Title>
<Author>Progress</Author>
<Shortcut>radgridsqlprog</Shortcut>
<Description>Markup snippet for a RadGrid control created entirely in the code behind with declarative binding using DataSourceID</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML" Delimiter="^">
<![CDATA[
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
InsertCommand="INSERT INTO [Orders] ([OrderDate], [Freight], [ShipName], [ShipCountry]) VALUES (@OrderDate, @Freight, @ShipName, @ShipCountry)"
SelectCommand="SELECT [OrderID], [OrderDate], [Freight], [ShipName], [ShipCountry] FROM [Orders]"
UpdateCommand="UPDATE [Orders] SET [OrderDate] = @OrderDate, [Freight] = @Freight, [ShipName] = @ShipName, [ShipCountry] = @ShipCountry WHERE [OrderID] = @OrderID"
DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID"></asp:SqlDataSource>^end^]]>
</Code>
</Snippet>
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>RadGrid created Programmatically with SqlDataSource</Title>
<Author>Progress</Author>
<Shortcut>radgridsqlprog</Shortcut>
<Description>Markup snippet for a RadGrid control created entirely in the code behind with declarative binding using DataSourceID</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="HTML" Delimiter="^">
<![CDATA[
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
InsertCommand="INSERT INTO [Orders] ([OrderDate], [Freight], [ShipName], [ShipCountry]) VALUES (@OrderDate, @Freight, @ShipName, @ShipCountry)"
SelectCommand="SELECT [OrderID], [OrderDate], [Freight], [ShipName], [ShipCountry] FROM [Orders]"
UpdateCommand="UPDATE [Orders] SET [OrderDate] = @OrderDate, [Freight] = @Freight, [ShipName] = @ShipName, [ShipCountry] = @ShipCountry WHERE [OrderID] = @OrderID"
DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID"></asp:SqlDataSource>^end^]]>
</Code>
</Snippet>
</CodeSnippet>