Thanks FroggEye for your reply.
I have followed the article on cms form engine
http://devnet.kentico.com/Videos/API/Kentico-CMS-Form-Engine.aspx and used the example attached - basicform
I get the form item using
IDataClass formItem = DataClassFactory.NewDataClass(className, itemId);
the following line changed as there is no DataRow in formItem
//this.form.DataRow = formItem.DataRow;
this.form.DataRow = formItem.GetDataSet().Tables[0].Rows[0];
Then I get the following error
[NullReferenceException: Object reference not set to an instance of an object.]
CMS.FormControls.EditingFormControl.CreateChildControls() +104
System.Web.UI.Control.EnsureChildControls() +83
CMS.FormControls.Layout.CreateEditingFormControl(FormFieldInfo ffi) +216
CMS.FormControls.LayoutForm.AddFormElement(FormFieldInfo ffi, String ffType, String ffName) +184
CMS.FormControls.LayoutForm.GenerateMacroContent(Match match, Int32& actualPos) +192
CMS.FormControls.LayoutForm.LoadLayout() +179
CMS.FormControls.BasicForm.LoadFormLayout() +92
CMS.FormControls.BasicForm.LoadData(IDataContainer data) +1237
CMS.FormControls.BasicForm.CreateChildControls() +42
System.Web.UI.Control.EnsureChildControls() +83
CMS.FormControls.BasicForm.OnLoad(EventArgs e) +42
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Control.LoadRecursive() +145
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772