-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDefault.aspx.cs
33 lines (28 loc) · 1.29 KB
/
Default.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using DevExpress.Web;
using System;
using System.Collections;
using System.Web.Services;
public partial class _Default : System.Web.UI.Page {
protected void Page_Init(object sender, EventArgs e) {
((GridViewDataComboBoxColumn)grid.Columns["CountryID"]).PropertiesComboBox.DataSource = DataProvider.GetCountries();
((GridViewDataComboBoxColumn)grid.Columns["CityID"]).PropertiesComboBox.DataSource = DataProvider.GetCities();
if(!IsPostBack)
grid.DataBind();
}
protected void grid_DataBinding(object sender, EventArgs e) {
grid.DataSource = DataProvider.GetCustomers();
}
protected void grid_BatchUpdate(object sender, DevExpress.Web.Data.ASPxDataBatchUpdateEventArgs e) {
foreach(var args in e.InsertValues)
DataProvider.InsertCustomer((string)args.NewValues["CustomerName"], (int)args.NewValues["CountryID"], (int)args.NewValues["CityID"]);
foreach(var args in e.UpdateValues)
DataProvider.UpdateCustomer((int)args.Keys["CustomerID"], (string)args.NewValues["CustomerName"], (int)args.NewValues["CountryID"], (int)args.NewValues["CityID"]);
foreach(var args in e.DeleteValues)
DataProvider.DeleteCustomer((int)args.Keys["CustomerID"]);
e.Handled = true;
}
[WebMethod]
public static IEnumerable GetCities(int countryID) {
return DataProvider.GetCities(countryID);
}
}