473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DetailsView: Change TemplateField properties dynamically (vb)

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>
Nov 19 '05 #1
2 10273


Ctype(sender,DataGrid).Columns(i).Visible= False
'i is the index of your templatefield
"sck10" wrote:
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>

Nov 19 '05 #2
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>
|
|
|

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: pannonej | last post by:
I need to make change to a wav file properties. I need to change the title, author and other file properties. Is there a way to do this is vb.net? Also can I add new (or custom) file...
1
by: kjon | last post by:
Hi, I have a form which will perform some function in another module. After that, I need to update some form properties from within the module to show the status. How can I change the properties...
5
by: VB Programmer | last post by:
How can I change the font size of a text box dynamically? I tried this but it didn't work. It said 'Size is Read-Only'. Any other ways around this? Here's the code: txtDisplay.Font.Size = 10
2
by: Venkat Shiva Reddy | last post by:
Hi In one of my VB application, I need to change the group of MS Word 2000 documents Header and Footer contents automatically with VB code and i did it successfully but I could not change the...
11
by: john andrew | last post by:
-- hello When using properties with OOP, VB6 had Get/Let and VB.net has Readonly/and .... Are theses OOP concepts with Property use or only specific to Visual Basic properties, With this...
2
by: maflatoun | last post by:
Hi everyone, I have the following web user control. I like to set the properties dynamically without using page.databind. <uc1:partnerdownloads id="Partnerdownloads1" PropDomain="<%= Domain...
2
by: onionman07 | last post by:
I am having a problem with a program i am trying to develop that uses menus to modify and track current properties of controls on a form. I have 2 PictureBox controls where I can choose how to...
3
by: Nick Bennett | last post by:
I've got a page with a DetailsView. It uses a SqlDataSource which itself uses stored procedures for Select and Update. I don't want the user to see some of the columns, but if I don't bind them...
3
by: reyo | last post by:
Hi, i design a dynamic web page.infact it will be a css generator. i have a question about visited link. i want to change color,font-size,font-weight etc. of a link when it is visited. when a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.