Hi Sck10,
Regarding on the problem you mentioned, we can access all the Fields we
defined in DetailsView control through its DetailsView.Fie lds 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 "EditTempla te" and put
nothing in "ItemTempla te" , 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.n ospam>
| 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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: 189.202.185.135 .in-addr.arpa 135.185.202.189
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1362 12
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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_PreRen der(ByVal sender As Object, ByVal e As
| EventArgs) Handles dvDetail.PreRen der
| If Me.dvDetail.Cur rentMode = DetailsViewMode .Edit Then
| MyTemplate.Visi ble = True
| End If
| End Sub
|
|
| <asp:TemplateFi eld
| Visible="false"
| HeaderText="Act ivity Date">
| <ItemTemplate >
| <asp:Label ID="lblActivity Date" Text='<%# Eval("ActivityD ate",
| "{0:d}") %>' Runat="Server"/>
| </ItemTemplate>
| <EditItemTempla te>
| <asp:TextBox id="txtActivity Date" Text='<%# Bind("ActivityD ate",
| "{0:d}") %>' Runat="Server" />
| </EditItemTemplat e>
| </asp:TemplateFie ld>
|
|
|