ASP .NET DetailsView TemplateField Control Enabled bindingASP .NET DetailsView TemplateField Control Enabled binding
Old forum URL: forums.lhotka.net/forums/t/4316.aspx
Plowking posted on Friday, February 08, 2008
Hi
I have a User object, with an Organisation property. A few super users are authorised to alter a User's Organisation. Therefore I would like to control the enabled property of my Organisation UI Control (a DropDownList) by binding to my User objects IsOrganisationAdministrator property.
In reality the IsOrganisationAdministrator property looks at a custom Identity Object to find out the CURRENT logged on user's authorisation level.
<asp:TemplateField HeaderText="Organisation" SortExpression="Organisation">
<ItemTemplate>
<asp:DropDownList ID="OrganisationDropDownList" runat="Server" Width="100%"
DataSourceID="OrganisationListDataSource" DataTextField="Value" DataValueField="Key"
enabled='<%# Bind("IsOrganisationAdmin") %>'
SelectedValue='<%# Bind("OrganisationID") %>' />
</ItemTemplate>
</asp:TemplateField>
I tried controlling the enabled status in page load, but it seems to get overriden somewhere else.
Cheers,
Ian
Plowking replied on Friday, February 08, 2008
I'm sorry this is working now. I had tried adding the IsOrganisationAdmin property to my PropertiesToIgnore list in my datasource_InsertObject and Update_Object event handlers, and it didnt work first time round, but now it's playing ball...
Csla.Data.DataMapper.Map(e.Values, obj, PropertiesToIgnore.ToArray)
It's nice that it works :)
Copyright (c) Marimer LLC