473,756 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing the properties of a control within an emptydatatempla te

2 New Member
I am using the emptydatatempla te for a gridview control. I have a detailsview control within the emptydatatempla te. In the detailsview I have a templatefield that contains an imagebutton control and a textbox control.

Expand|Select|Wrap|Line Numbers
  1.             <EmptyDataTemplate>
  2.                 &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;
  3.                 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  4.                 <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="ActivityTypeControl_ID"
  5.                     DataSourceID="spListActivityTypeControlByType" DefaultMode="Insert" Height="50px"
  6.                     Width="125px" BackColor="#090AAAA" OnPageIndexChanging="DetailsView1_PageIndexChanging1" BorderStyle="None" GridLines="None" OnItemCommand="DetailsView1_ItemCommand">
  7.                     <Fields>
  8.                        <asp:TemplateField HeaderText="Begin Date" SortExpression="BeginDate">
  9.                             <InsertItemTemplate>
  10.                                 &nbsp;<asp:TextBox ID="txtIBeginDate" runat="server" Text='<%# Bind("BeginDate") %>' Width="90px"></asp:TextBox>
  11.                                 <asp:ImageButton ID="imgbutICalendar1" runat="server" ImageUrl="~/Images/APPTL.ICO" Height="16px" 
  12.                                 Width="16px" OnClick="imgbutCalendar_Click" />
  13.                             </InsertItemTemplate>
  14.                         </asp:TemplateField>
  15.                  </asp:DetailsView>
  16.             </EmptyDataTemplate>
  17.  
When the user clicks on the imagebutton I look at the text in the textbox and display a calendar control.

Expand|Select|Wrap|Line Numbers
  1.     Private ParentControl As Control
  2.     Protected Sub imgbutCalendar_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs)
  3.      Dim txtDate as TextBox
  4.  
  5.      ParentControl = DirectCast(sender, Control).Parent
  6.      txtDate = ParentControl.FindControl("txtIBeginDate")
  7.  
  8.      Calendar.VisibleDate = CDate(txtDate.Text)
  9.      Calendar.Visible = True  
  10.     End Sub
  11.  
This displays the calendar with the month I would expect. However, I then want to change the text property of my textbox (txtIBeginDate) with the date that was selected from the calendar control.

I am doing this using the calendar's selectionchange d event using the following code.

Expand|Select|Wrap|Line Numbers
  1.     Protected Sub Calendar_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar.SelectionChanged
  2.         Calendar.Visible = False
  3.         Dim txtDate As TextBox
  4.  
  5.         txtDate = ParentControl.FindControl(Session("txtIBeginDate"))
  6.         txtDate.Text = Calendar.SelectedDate.ToShortDateString
  7.     End Sub
  8.  
If I step through my code in debug everything seems to get set correctly. However, when my page is redisplayed the value in my textbox is left unchanged.

Can anyone explain what I am doing wrong?
Nov 6 '08 #1
1 2027
iam_clint
1,208 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. Dim txtDate As TextBox 
  2. txtDate = ParentControl.FindControl(Session("txtIBeginDate")) 
  3. txtDate.Text = Calendar.SelectedDate.ToShortDateString 
  4.  
I see here you are dimming txtDate as TextBox... in your aspx code do you have something like this
Expand|Select|Wrap|Line Numbers
  1. <asp:textbox runat="server" id="txtDate"></asp:textbox>
If so there is no need to dim txtDate as TextBox. i'm not 100% sure this is the problem you are experiencing.. Also another look into things... in your page load are you setting txtDate.text to anything? maybe you need an ispostback check.
Nov 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3381
by: Jaweed | last post by:
Hi I'm developing an ASP.NET app in Visual studio (using C# for code behind). My question is fairly simple (i think). When I go to the code behind page, the controls in the html page are made "protected" so that it can only be accessed from within that page. I would like to permanently make this "public" for certain controls, so that I can access them from another page (the page that a user control is embedded into for example). If I...
2
3182
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the problems that I have encountered to date and the solutions (if any) that I found. http://users.adelphia.net/~brianpclab/ServerControlCollectionIssues.htm This page also has all of the source code in a compressed file that you are free to download...
5
3792
by: g6023 | last post by:
Hi All Newbie to C# I am afraid The array of panel dispays OK but I am having problems with accessing the controls within. My panels each have a number of label controls. How do I set, say, the Name.Text property in List<Panel> ListPanelArray
0
1224
by: rodchar | last post by:
hey all, whenever i add any kind of control to the EmptyDataTemplate and browse to that page there's like a sunken border around the control. Is there anyway to remove that? i looked at the source and there's no Div or style that i know that's telling it to do that. thanks, rodchar
4
1828
by: Torben Laursen | last post by:
I want to change the label of a component that I have on a masterpage but I cannot get my hands on it I have a mastepage MP2 that has a button called B2 masterpage MP2 uses masterpage MP1 that has a button called B1 I then have a page called default and in the page load I tryed: System.Web.UI.WebControls.Button B10 = (System.Web.UI.WebControls.Button)Master.FindControl("B1"); System.Web.UI.WebControls.Button B20 =...
1
7285
by: Jeff | last post by:
hi asp.net 2.0 I have a GridView here with some controls in it's EmptyDataTemplate. I'm wondering how I can get access to those controls. I've tryed using FindControl, but that doesn't work because EmptyDataTemplate doesn't have that method <EmptyDataTemplate>
1
1957
by: ranger979 | last post by:
I am using the emptydatatemplate for a gridview control. I have a detailsview control within the emptydatatemplate. In the detailsview I have another templatefield that contains an imagebutton control and a textbox control. <EmptyDataTemplate> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:DetailsView ID="DetailsView1"...
1
8830
by: bradleyhogan | last post by:
I've tried various ways to get data value(s) from a DataList control (with same results for ListView and FormView). These are my attempts: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dli As DataListItem For Each dli In DataList1.Items Dim theValue As String = CType(DataList1.FindControl("AttendeeMailLabel"), Label).Text ...
3
8417
by: BiffMaGriff | last post by:
Hello, I want to use the GridView footer for inserting new items into my table. However when the table is empty I'm forced to see the EmptyDataTemplate. Is there a way to disable using the EmptyDataTemplate? If not, what are some strategies for overcoming this? I'm binding to a strongly typed object data source. Thanks, -Biff
0
9275
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
10034
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
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
9843
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,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
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
5142
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
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.