473,769 Members | 2,003 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 2030
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
3793
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
1226
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
1830
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
7288
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
1958
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
8419
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
9589
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
10211
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
10045
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...
0
9863
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
7409
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
6673
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
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
2
3562
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.