-
Notifications
You must be signed in to change notification settings - Fork 1
/
Default1.aspx.cs
34 lines (26 loc) · 1.37 KB
/
Default1.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
34
using System;
using System.Data.OleDb;
using System.Web.Configuration;
using DevExpress.Web;
public partial class Default1 : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void cb_Init(object sender, EventArgs e) {
ASPxCheckBox checkBox = (ASPxCheckBox)sender;
GridViewDataItemTemplateContainer container = (GridViewDataItemTemplateContainer)checkBox.NamingContainer;
string key = string.Format("{0}_{1}", container.Column.FieldName, container.KeyValue);
checkBox.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ hf.Set('{0}', s.GetChecked()); }}", key);
}
protected void ASPxButton1_Click(object sender, EventArgs e) {
foreach (var item in ASPxHiddenField1) {
string[] parts = item.Key.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
bool value = (bool)item.Value;
OleDbConnection connection = new OleDbConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
OleDbCommand updateCommand = new OleDbCommand(string.Format("UPDATE Settings SET {0} = {1} WHERE Id = {2}", parts[0], value, parts[1]), connection);
connection.Open();
updateCommand.ExecuteScalar();
connection.Close();
}
ASPxHiddenField1.Clear();
}
}