Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 24th, 2008, 06:08 PM
Authorized User
Join Date: Apr 2008
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to AspNetGuy
Default SqlDataSource ControlParameter Cannot Find Control

I am using asp:TemplateField instead of asp:BoundField. I have coded a TextBox inside a DetailsView. I then coded a SqlDataSource asp:ControlParameter and the ControlParameter cannot find the TextBox. Is this another case of needing FindControl? Below is the pertinent code, minus the validators.

<asp:DetailsView ID="SchedulingDetailsView" runat="server"
    OnItemInserted="SchedulingDetailsView_ItemInserted "
       <asp:Label ID="lblDepartureDate" runat="server"
            Text="Departure Date:">
         <asp:TextBox ID="tbDepartureDate" runnat="server"

<asp:SqlDataSource ID="SqlTrips" runat="server"
  ConnectionString="<%$ ConnectionStrings:fireConnection %>"
  InsertCommand="INSERT INTO [fireTrips] ([DepartureDate],[ReturnDate],[DestinationCity],[DestinationCountry],[TripDescription],[Cost],[TripStatus],[Availability]) VALUES (@DepartureDate, @ReturnDate, @DestinationCity, @DestinationCountry, @TripDescription, @Cost, @TripStatus, @Availability)"
  <asp:ControlParameter ControlID="tbDepartureDate" Name="DepartureDate" Type="DateTime" />


How do I access the controls inside the DetailsView from the ControlParameter.

Thanks in advance for any help given.

Old June 25th, 2008, 07:44 AM
Authorized User
Join Date: Apr 2008
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to AspNetGuy

The problem was solved by adding Text='<%# Bind("DepartureDate") %>'> to each of the fields. Changing DepartureDate to the appropriate column name.

I discovered this by creating an asp:BoundField and then converting it to a asp:TemplateField and examining what the converted asp:TemplateField looked like.

So the connection between a TemplateField contained control and the SqlDataSource is the Text parameter of the control.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with SqlDataSource control binici ASP.NET 2.0 Basics 1 February 5th, 2007 05:32 PM
SqlDataSource control error binici ASP.NET 2.0 Basics 1 January 19th, 2007 08:02 PM
SqlDataSource + controlparameter + Calendar issue AbrarNazeer ASP.NET 2.0 Professional 0 September 21st, 2006 06:57 AM
SqlDatasource filter using formview control tony_j_hug ASP.NET 2.0 Basics 2 October 17th, 2005 05:55 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.