Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2009, 05:26 AM
Registered User
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default showing / hiding template fields in detailsview

Hi, I have a detailsview control in which I would like to hide a templatefield when the control is in read only mode and display the template when the form is in edit mode.
here is the snipet from the details view control. I dont want to be able to see the header text at all in readonly mode.
<asp:TemplateFieldHeaderText="Access Type" visible = "false">
<ItemTemplate><asp:Labelid="lblAccessId"runat="server"Text='<%# Eval("_accessLevelID") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownListID="ddlaccessTypes"runat="server"DataSourceID="objAllAccessTypes"DataTextField="_accessLevelType"DataValueField="_accessLevelID"
selectedValue='<% # bind("_accessLevelId") %>'
/></EditItemTemplate>
</asp:TemplateField>
and here is the snippet from the code behind file
ProtectedSub dvProviders_PreRender(ByVal sender AsObject, ByVal e As EventArgs)

If dv_providers.CurrentMode = DetailsViewMode.Edit Then

dv_providers.Rows(16).Visible = True

EndIf
EndSub


If I set the <asp:TemplateFieldHeaderText="Access Type" visible = "false">

then the Sub dvProviders_PreRender doesnt display the row when the template is in edit mode.

I suspect that this is because visible is set to false in the template which ultimately overrides the onprerender event.

The details view control is only displayed once a selection is made from a listbox on the page.

The solution must lie in being able to set the visiblle attribute of the template to false programmatically but I'm not sure how to do this when the detailsview control doesnt exist on the page until
a selection is made from the list box.

I have looked at many posts on this topic but cant find a solution. Any help would be appreciated.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cascading dropdownlists not working in the edit template of detailsview thd_tq123 ASP.NET 3.5 Professionals 1 February 27th, 2009 07:55 AM
Pure CSS Menu Showing Behind Form Fields in IE kwilliams CSS Cascading Style Sheets 10 November 19th, 2007 10:25 AM
Filtering Template columns in Detailsview shashipandey ASP.NET 2.0 Professional 0 September 20th, 2007 04:58 AM
hiding and showing the table in html through xslt nachiketha XSLT 6 March 16th, 2007 01:12 AM
Access Reports - hiding blank fields Gandalf_the_Grey Access 3 December 12th, 2006 07:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.