// Persist unbound data here protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { object key = e.Keys[0]; string newComment = (string)e.NewValues["Comment"]; MyComments.SetComment(key, newComment); }
// Fetch unbound data here protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e) { if (e.IsGetData && e.Column.FieldName == "Comment") { object key = e.GetListSourceFieldValue(e.ListSourceRowIndex, ASPxGridView1.KeyFieldName); e.Value = MyComments.GetComment(key); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && !IsCallback) { // predefine one comment MyComments.SetComment(2, "It's me"); } }
// And save it protected void AccessDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e) { if (pendingComment != null && e.AffectedRows == 1) { System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("SELECT @@IDENTITY"); cmd.Connection = (System.Data.OleDb.OleDbConnection)e.Command.Connection; object newID = cmd.ExecuteScalar(); MyComments.SetComment(newID, pendingComment); pendingComment = null; } }
// Persist unbound data here protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { // main data is read-only to keep this example simple e.Cancel = true; ASPxGridView1.CancelEdit(); // only unbound data is editable object key = e.Keys[0]; string newComment = (string)e.NewValues["Comment"]; MyComments.SetComment(key, newComment); }
protected void Page_Load(object sender, EventArgs e) { ASPxGridView1.DataSource = GetData(); if (!IsPostBack && !IsCallback) { // pre-define one comment MyComments.SetComment(2, "It's me"); // call DataBind on the first page load // if the grid's DataSource is assigned in code behind ASPxGridView1.DataBind(); } }