This is just off the top of my head & untested, but here goes....
PropertyBag["CurSysCheckNameList"]=Enum.GetName(typeof(SystemChecks),
CurrentJobInformation.SystemIncludes).Split(new char[] {',', ' '},
StringSplitOptions.RemoveEmptyEntries);
#foreach($SysCheck in $CurSystemChecks)
<input type="checkbox"
name="TktInstallationInfo.JobInformation.SystemIncludes"
#if ($CurSysCheckNameList.Contains($SysCheck)) checked="checked" #end
value="$SysCheck" /> $SysCheck
#end
On Tue, Aug 11, 2009 at 1:59 PM, JakeS<[email protected]> wrote:
>
> Sorry, alt +tab doesn't increase indent here, it goes to SEND
>
> Here's what I was trying to say:
>
> I'm trying to databind to a property that's defined as an Enum. I
> looked at
> http://markmail.org/message/qnuhdzdbm2iqpm24#query:FormHelper.CreateCheckboxList%20enum+page:1+mid:qnuhdzdbm2iqpm24+state:results
> as an example. Here's what I've managed so far:
>
> [Flags]
> public enum SystemChecks
> {
> Fire = 1,
> CarbonMonoxide = 2,
> Flood = 4,
> Medical = 8
> }
> [ActiveRecord]
> public class JobInformation : ModelBase<JobInformation>
> {
> [Property]
> public SystemChecks SystemIncludes { get; set; }
> }
>
> In my controller I've got something like this:
> public void EditJobInformation()
> {
> PropertyBag["CurJobInfo"] = CurrentJobInformation;
>
> PropertyBag["CurSystemChecks"] = Enum.GetNames(typeof
> (SystemChecks));
> PropertyBag["CurSysCheckName"]=Enum.GetName(typeof(SystemChecks),
> CurrentJobInformation.SystemIncludes);
> }
> public void UpdateJobInformation([DataBind("CurJobInfo")]
> JobInformatiom UpdatedJobInformation)
> {
> // Save it here
> }
>
> And my view has the following:
> #foreach($SysCheck in $CurSystemChecks)
> <input type="checkbox"
> name="TktInstallationInfo.JobInformation.SystemIncludes"
> value="$SysCheck" /> $SysCheck
> #end
>
> It's all working except the view doesn't show which SystemChecks were
> already selected. Is there an easy way to make the correct checkboxes
> already selected? I'd tried FormHelper.CreateCheckboxList before this
> and had the opposite problem, it would create the checkboxes selected
> properly, but the JobInformation passed back to the
> UpdateJobInformation action was not updated with the new selections.
> >
>
--
Truth,
James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---