473,385 Members | 1,888 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.

Declaring controls in FormView

Hi!

I am new to .net (vb) and moving from classic asp. I ran into a problem
that has left me with less hair on my head.

For some reason, my button and calendar that sits inside an
insertItemTemplate in a FormView, will not allow me to declare it. The
controls (Calendar1, InvoiceDate) are in the page and names are
correct. Here is the sub I am using.

<script language="VB" runat="server">

' when the button is clicked the calendar is visible

Sub showcal1(ByVal sender As Object, ByVal e As EventArgs)
Calendar1.Visible = True
End Sub
' this takes the date selected from the calendar and places it in a
textbox.
Sub Date_Selected(ByVal sender As Object, ByVal e As EventArgs)
InvoiceDate.Text = Calendar1.SelectedDate.ToShortDateString
Calendar1.Visible = False
End Sub

</script>

This works fine if it is not inside the FormView control. I am using
inline code for this task. Below is the entire of code. Any help would
be greatly appreciated. ; )
<script language="VB" runat="server">

' when the button is clicked the calendar is visible

Sub showcal1(ByVal sender As Object, ByVal e As EventArgs)
Calendar1.Visible = True
End Sub
' this takes the date selected from the calendar and places it in a
textbox.
Sub Date_Selected(ByVal sender As Object, ByVal e As EventArgs)
InvoiceDate.Text = Calendar1.SelectedDate.ToShortDateString
Calendar1.Visible = False
End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="ts.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<table align="center" bgcolor="#ffffff" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td style="height: 10px">
<img id="interface_r1_c5" alt="" border="0"
height="10" name="interface_r1_c5"
src="assets/layout/images/interface_r1_c5.gif"
width="10" /></td>
<td style="height: 10px">
<img id="interface_r1_c6" alt="" border="0"
height="10" name="interface_r1_c6"
src="assets/layout/images/interface_r1_c6.gif"
width="620" /></td>
<td style="height: 10px">
<img id="interface_r1_c7" alt="" border="0"
height="10" name="interface_r1_c7"
src="assets/layout/images/interface_r1_c7.gif"
width="10" /></td>
</tr>
<tr>
<td
background="assets/layout/images/interface_r2_c5.gif">
<img id="interface_r2_c5" alt="" border="0"
height="70" name="interface_r2_c5"
src="assets/layout/images/interface_r2_c5.gif"
width="10" /></td>
<td bgcolor="#ffffff" class="content" valign="top">
<h2>
Invoicer</h2>

<p>&nbsp;</p>
<p>
&nbsp;<asp:AccessDataSource
ID="AccessDataSource1" runat="server" DataFile="~/db/db.MDB"
SelectCommand="SELECT * FROM [tblInvoice]"
DeleteCommand="DELETE FROM [tblInvoice] WHERE [ID] = ?"
InsertCommand="INSERT INTO [tblInvoice] ([ID], [Client], [InvoiceDate],
[ServiceType], [TotalHours], [HourlyRate], [Archived]) VALUES (?, ?, ?,
?, ?, ?, ?)" UpdateCommand="UPDATE [tblInvoice] SET [Client] = ?,
[InvoiceDate] = ?, [ServiceType] = ?, [TotalHours] = ?, [HourlyRate] =
?, [Archived] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32"
/>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Client"
Type="String" />
<asp:Parameter Name="InvoiceDate"
Type="DateTime" />
<asp:Parameter Name="ServiceType"
Type="String" />
<asp:Parameter Name="TotalHours"
Type="Int32" />
<asp:Parameter Name="HourlyRate"
Type="Decimal" />
<asp:Parameter Name="Archived"
Type="Boolean" />
<asp:Parameter Name="ID" Type="Int32"
/>
</UpdateParameters>
<InsertParameters>

<asp:Parameter Name="ID" Type="Int32"
/>
<asp:Parameter Name="Client"
Type="String" />
<asp:Parameter Name="InvoiceDate"
Type="DateTime" />
<asp:Parameter Name="ServiceType"
Type="String" />
<asp:Parameter Name="TotalHours"
Type="Int32" />
<asp:Parameter Name="HourlyRate"
Type="Decimal" />
<asp:Parameter Name="Archived"
Type="Boolean" />
</InsertParameters>
</asp:AccessDataSource>
</p>
<asp:FormView ID="FormView1" runat="server"
DataKeyNames="ID" DataSourceID="AccessDataSource1">
<EditItemTemplate>

ID:
<asp:Label ID="IDLabel1" runat="server"
Text='<%# Eval("ID") %>'></asp:Label><br />
Client:
<asp:TextBox ID="ClientTextBox"
runat="server" Text='<%# Bind("Client") %>'>
</asp:TextBox><br />
InvoiceDate:
<asp:TextBox ID="InvoiceDateTextBox"
runat="server" Text='<%# Bind("InvoiceDate") %>'>
</asp:TextBox><br />
ServiceType:
<asp:TextBox ID="ServiceTypeTextBox"
runat="server" Text='<%# Bind("ServiceType") %>'>
</asp:TextBox><br />
TotalHours:
<asp:TextBox ID="TotalHoursTextBox"
runat="server" Text='<%# Bind("TotalHours") %>'>
</asp:TextBox><br />
HourlyRate:
<asp:TextBox ID="HourlyRateTextBox"
runat="server" Text='<%# Bind("HourlyRate") %>'>
</asp:TextBox><br />
Archived:
<asp:CheckBox ID="ArchivedCheckBox"
runat="server" Checked='<%# Bind("Archived") %>' /><br />
<asp:LinkButton ID="UpdateButton"
runat="server" CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>

<table>
<tr>
<td >
Client:</td>
<td style="width: 233px" >
<asp:TextBox ID="Client"
runat="server"></asp:TextBox></td>
</tr>
<tr>
<td valign="top">
Date:</td>
<td valign="top" style="width: 233px">
<asp:TextBox ID="InvoiceDate" runat="server"
Width="57px" ReadOnly="True"></asp:TextBox>
<asp:Button ID="Button1" onClick="showcal1"
runat="server" Text="Date Picker" Width="33px" />
<br />
<asp:Calendar ID="Calendar1"
onselectionchanged="Date_Selected" runat="server"
Visible="False"></asp:Calendar> </td>
</tr>
<tr>
<td >
Type of service</td>
<td style="width: 233px" >
<asp:TextBox ID="ServiceType"
runat="server" Width="224px"></asp:TextBox></td>
</tr>
<tr>
<td >
Hours</td>
<td style="width: 233px" >
<asp:TextBox ID="TotalHours"
runat="server" Width="56px"></asp:TextBox></td>
</tr>
<tr>
<td >
Hourly Rate</td>
<td style="width: 233px" >
<asp:TextBox ID="HourlyRate"
runat="server"></asp:TextBox></td>
</tr>
<tr>
<td >&nbsp;</td>
<td style="width: 233px" ><asp:Button
ID="Button2" Text="Submit" runat="server" /></td>
</tr>
</table>
<br />
<asp:LinkButton ID="InsertButton"
runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
ID:
<asp:Label ID="IDLabel" runat="server"
Text='<%# Eval("ID") %>'></asp:Label><br />
Client:
<asp:Label ID="ClientLabel" runat="server"
Text='<%# Bind("Client") %>'></asp:Label><br />
InvoiceDate:
<asp:Label ID="InvoiceDateLabel"
runat="server" Text='<%# Bind("InvoiceDate") %>'></asp:Label><br />
ServiceType:
<asp:Label ID="ServiceTypeLabel"
runat="server" Text='<%# Bind("ServiceType") %>'></asp:Label><br />
TotalHours:
<asp:Label ID="TotalHoursLabel"
runat="server" Text='<%# Bind("TotalHours") %>'></asp:Label><br />
HourlyRate:
<asp:Label ID="HourlyRateLabel"
runat="server" Text='<%# Bind("HourlyRate") %>'></asp:Label><br />
Archived:
<asp:CheckBox ID="ArchivedCheckBox"
runat="server" Checked='<%# Bind("Archived") %>'
Enabled="false" /><br />
<asp:LinkButton ID="EditButton"
runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="DeleteButton"
runat="server" CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
<asp:LinkButton ID="NewButton"
runat="server" CausesValidation="False" CommandName="New"
Text="New"></asp:LinkButton>
</ItemTemplate>
</asp:FormView>

</td>
<td
background="assets/layout/images/interface_r2_c7.gif">
<img id="interface_r2_c7" alt="" border="0"
height="70" name="interface_r2_c7"
src="assets/layout/images/interface_r2_c7.gif"
width="10" /></td>
</tr>
<tr>
<td >
<img id="interface_r3_c5" alt="" border="0"
height="10" name="interface_r3_c5"
src="assets/layout/images/interface_r3_c5.gif"
width="10" /></td>
<td >
<img id="interface_r3_c6" alt="" border="0"
height="10" name="interface_r3_c6"
src="assets/layout/images/interface_r3_c6.gif"
width="620" /></td>
<td >
<img id="interface_r3_c7" alt="" border="0"
height="10" name="interface_r3_c7"
src="assets/layout/images/interface_r3_c7.gif"
width="10" /></td>
</tr>
</table>
</form>
</body>
</html>

Jan 29 '06 #1
1 1645
Got it.... had to dim them up and add FindControl...

Sub showcal1(ByVal sender As Object, ByVal e As EventArgs)
FormView1.FindControl("Calendar1").Visible = True
End Sub

Sub Date_Selected(ByVal sender As Object, ByVal e As EventArgs)

Dim invdate
invdate = FormView1.FindControl("InvoiceDate")
Dim clnd
clnd = FormView1.FindControl("Calendar1")

invdate.text = clnd.SelectedDate.ToShortDateString()
FormView1.FindControl("Calendar1").Visible = False

End Sub

Jan 30 '06 #2

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

Similar topics

0
by: Neil | last post by:
I want to be able to set the enabled status of certain controls on the edititem template of a formview control based on whether a check box is checked or not (or the value coming from the database...
3
by: Scott at Cedar Creek | last post by:
Can I put a repeater inside a FormView? Can I put a repeater inside that repeater? If so, what happens when the FormView.Mode is "Edit?" When they click the EDIT button is my repeater data also...
0
by: Hawk | last post by:
Hello, this is my first post hope to get some good answers. I am using asp.net 2.0 and I am trying to pass the value entered in the formview textbox in insert mode "in this case it is the...
4
by: Ned Balzer | last post by:
Can anyone explain why in the following code, where btnCancel1 is a Button inside the itemTemplate of the formview, the first call to change the text of the button, in the Page_Load sub, works...
2
by: wikkiwikkiwaa | last post by:
hello, i am trying to access controls inside my formview1 nested inside loginview1. you cannot access the formview1 unless you are properly logged in. for loginview1, that seems to be fairly...
6
by: J055 | last post by:
Hi I have a FormView, Panel and ObjectDataSource control. I'm trying to change the Panel.Visible property to true based on a value in the ReturnValue object in the ObjectDataSource.Selected...
2
by: Nathan Sokalski | last post by:
I am trying to create a FormView controls in which I access and modify the the controls in the PagerTemplate programmatically. However, I continue to recieve the following error: Object...
0
by: Rafter | last post by:
Hi, I am using a server controls (textbox, dropdownlist, calendar) inside of a form view, it seems that the .Net framework (VB.Net & Net Frame Work 2.0) makes it difficult to access the control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.