Conditionally Making Grid Row Editable in EP Axapta

This is code hint to Conditionally Making Grid Row Editable in Enterprise Portal in  Axapta .


 public partial class AxWebUserControl : System.Web.UI.UserControl  
 {  
  void Page_Init(object sender, EventArgs e)  
 {  
 this.AxGridView1.SelectedIndexChanged += new EventHandler(AxGridView1_SelectedIndexChanged);  
 }  
  void AxGridView1_SelectedIndexChanged(object sender, EventArgs e)  
 {  
 this.EnableGridEditing(this.IsCurrentAccountNumberEven());  
 }  
 private void EnableGridEditing(bool enable)  
 {  
  if (enable)  
  {  
  this.AxGridView1.AllowEdit = true; this.AxGridView1.EditIndex = this.AxGridView1.SelectedIndex;  
  }  
 else  
 {  
  this.AxGridView1.EditIndex = -1;  
  this.AxGridView1.AllowEdit = false;  
  }  
 }  
 private bool IsCurrentAccountNumberEven()  
 {  
  DataSet dataSet = this.CustomersInfoDS.GetDataSet();  
 DataSetViewRow currentRow = dataSet.DataSetViews[this.AxGridView1.DataMember].GetCurrent();  
 if (currentRow != null)  
 {  
 string accountNumberStr = (string)currentRow.GetFieldValue("AccountNum");  
  if (!string.IsNullOrEmpty(accountNumberStr))  
 {  
 int accountNumber = Int32.Parse(accountNumberStr);  
 return accountNumber % 2 == 0;  
 }  
  }  
  return false  
  }