hello,
im on an older version of RadControls for ASP.NET AJAX ("2009.2 826") but i think the answer to my question should be pretty straight-forward.
im using a RadGrid that uses WebUserControl for the grid's EditFormType. This .ascx form is displayed for Insertion and Update operations. my question -- in the user control's code-behind, how can i tell which mode the code is being executed as? i use this to show different things if the user is performing an Insert vs. an Update.
currently i use this code in the user control's .ascx.cs:
...is there a better way than doing the Object.ReferenceEquals on the DataItem's type (comparing it to a GridInsertionObject's type) ?
thanks!
matt
im on an older version of RadControls for ASP.NET AJAX ("2009.2 826") but i think the answer to my question should be pretty straight-forward.
im using a RadGrid that uses WebUserControl for the grid's EditFormType. This .ascx form is displayed for Insertion and Update operations. my question -- in the user control's code-behind, how can i tell which mode the code is being executed as? i use this to show different things if the user is performing an Insert vs. an Update.
currently i use this code in the user control's .ascx.cs:
private void Page_PreRender(object sender, EventArgs e){ //this is the only way i know how to check what mode this grid control is operating in. bool isGridInsertion = Object.ReferenceEquals(this.DataItem.GetType(), new GridInsertionObject(new ArrayList()).GetType() ); if (isGridInsertion != true) //we check this because the below int assignment breaks on a grid insertion (since ProductTypeID has no value during our Insert form, only populated on Edit)
{ int productTypeID = (int)DataBinder.Eval(this.DataItem, "ProductTypeID"); // do stuff }}...is there a better way than doing the Object.ReferenceEquals on the DataItem's type (comparing it to a GridInsertionObject's type) ?
thanks!
matt