473,770 Members | 4,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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


Ctype(sender,Da taGrid).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_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>

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.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>
|
|
|

Nov 19 '05 #3

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

Similar topics

1
5640
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 properties to file in vb.net?
1
1267
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 in the form without declaring the form as public? Thanks.
5
130338
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
1569
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 properties like title, subject, author as a batch process. Could any one help me out Thanks in advance Venka
11
1796
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 property use does C++ have this as well or just Visual C++.?
2
1405
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 %>" PropPartnerUserGroupID="<%= PartnerUserGroupID %>" runat="server"></uc1:partnerdownloads> However, and <%= Domain %>
2
1156
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 change their properties. What I have to do is change colors, increase or decrease the size by 5 pixels or move them in any direction 10 pixels. I also have a Menu Item that you can choose whether you want to see 1 or 2 picture boxes.
3
1535
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 (or if I do bind them but set Visible=False), when the Update procedure is called, the parameters corresponding to the columns that weren't bound to the DetailsView are all null. This can't be an uncommon scenario, so I guess I have missed...
3
3858
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 user change font-size dynamically visited link's font-size will be change. i use dropdown list for font-size values . there are 24 links on the page.links id="a1" a2,a3, so on.. function denemelink(){ var...
0
9602
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10071
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.