Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Bizform FieldControls Handling View modes: 
User avatar
Member
Member
tspring-allegra - 5/21/2012 12:24:59 PM
   
Bizform FieldControls Handling
Hi,

I'm trying to update some custom bizfrom code from 4.1 to 6.0 but have a problem accessing the form field controls.

Previously to access a drop down list control I had the following code:
System.Web.UI.WebControls.DropDownList myform_drop1 = (System.Web.UI.WebControls.DropDownList)viewBiz.BasicForm.FieldControls["Drop1"];
string drop1_Option = myform_drop1.SelectedIndex.ToString();

...but I now get an error "Unable to cast object of type 'ASP.cmsformcontrols_basic_textboxcontrol_ascx' to type 'System.Web.UI.WebControls.TextBox'."

Does anyone know the correct code update to fix this?

Thanks,
Tim

User avatar
Member
Member
kentico_michal - 5/22/2012 2:44:46 AM
   
RE:Bizform FieldControls Handling
Hi,

You can try to use the following code to get the selected value:

if (viewBiz.BasicForm.FieldEditingControls != null)
{
EditingFormControl ctrl = viewBiz.BasicForm.FieldEditingControls["<name>"] as EditingFormControl;
string value = ctrl.Value.ToString();
}


Best regards,
Michal Legen

User avatar
Member
Member
tspring-allegra - 5/22/2012 4:04:04 AM
   
RE:Bizform FieldControls Handling
Thanks Michal, that worked great.

I'm also trying to update the code that sets bizform data using the old code:
viewBiz.BasicForm.DataRow["Field"] = New_Value;


I see in the help file: http://devnet.kentico.com/docs/devguide/index.html?api_bizforms_customization_possibilities.htm

It's now:
BasicForm.SetDataValue(string fieldName, object value)

But if I use this I get an error: "'CMS.FormControls.BasicForm.SetDataValue(string, object)' is inaccessible due to its protection level"

I'm not sure what this means?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 5/22/2012 6:58:49 AM
   
RE:Bizform FieldControls Handling
Hi,

you need to create a BasicForm object first and then call the method.

viewBiz.BasicForm.SetDataValue("FirstName"), "N/A")

Example you can find in for example Modify code of a standard web part article.

Or are you already using this method in above format and code you provided is only copy/paste error where viewBiz was lost?

Best regards,
Ivana Tomanickova

User avatar
Member
Member
tspring-allegra - 5/25/2012 9:05:47 AM
   
RE:Bizform FieldControls Handling
Hi,

I found simple using: viewBiz.BasicForm.Data["fieldname"] worked as a code replacement.

Thanks again.

Tim