Hi Sck10,
Regarding on the problem you mentioned, we can access all the Fields we
defined in DetailsView control through its DetailsView.Fields Property
(through index..)
And of course we can change a certain one's Visble propety. However, as you
mentioned that what you need is hidden the TemplateField in normal status ,
but make it visible when DetailsView turn into Edit mode, yes? If so, we
can just put UI controls in that templateField's "EditTemplate" and put
nothing in "ItemTemplate" , thus there will only displaying UI for that
TemplateField in edit mode. Does this also meet your requirement?
If there're any other questions on this, please feel fee to post here.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "sck10" <sc***@online.nospam>
| Subject: DetailsView: Change TemplateField properties dynamically (vb)
| Date: Fri, 4 Nov 2005 14:00:08 -0600
| Lines: 29
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <u9**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 189.202.185.135.in-addr.arpa 135.185.202.189
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:136212
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| I am trying to programically make the following TemplateField
("MyTemplate")
| visible when the user clicks on the "Edit" Button using the PreRender
handle
| event. My question is, how do you reference the properties of a
particular
| TemplateField? For example:
|
| Protected Sub dvDetail_PreRender(ByVal sender As Object, ByVal e As
| EventArgs) Handles dvDetail.PreRender
| If Me.dvDetail.CurrentMode = DetailsViewMode.Edit Then
| MyTemplate.Visible = True
| End If
| End Sub
|
|
| <asp:TemplateField
| Visible="false"
| HeaderText="Activity Date">
| <ItemTemplate>
| <asp:Label ID="lblActivityDate" Text='<%# Eval("ActivityDate",
| "{0:d}") %>' Runat="Server"/>
| </ItemTemplate>
| <EditItemTemplate>
| <asp:TextBox id="txtActivityDate" Text='<%# Bind("ActivityDate",
| "{0:d}") %>' Runat="Server" />
| </EditItemTemplate>
| </asp:TemplateField>
|
|
|