Problem with using FormView with asp:ControlParameter

Last post 07-08-2008 9:17 PM by Andrew Chan. 2 replies.

Sort Posts:

  • Crying [:'(] Problem with using FormView with asp:ControlParameter

    07-07-2008, 11:15 PM
    • Member
      2 point Member
    • Andrew Chan
    • Member since 07-07-2008, 10:39 PM
    • Hong Kong
    • Posts 6

    Dear All,

     Recently i face a problem, it report that it can't found the specific controls when post back the form to server side.

    The error code is ""Could not find control 'rbtnlst_Reason' in ControlParameter 'Reason'."

    However, i explicitly declare the control inside the InsertedItemTemplate of the FormView. Does anyone know what's going on here?  Are there any alternative routes to solve the problem? Thanks for all who reply this post.


    The page Code are listed as below, the word which is in red are the problem code:


    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Attendance_Register.aspx.vb" Inherits="Attendance_Apply_Attendance_Register" title="Attendance Register" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="bodyContentPlaceHolder" Runat="Server">  
        <h2>Attendance - Register</h2>
        <asp:FormView ID="AttendanceRegisterFormView" runat="server"
            DataSourceID="AttendanceRegisterSQL" DefaultMode="Insert">
                <InsertItemTemplate>
                    <table cellpadding="0" cellspacing="0" BorderColor="#ffffc0" border="1" class="style2">
                        <tr>
                            <td colspan="2" style="height: 30px" bgcolor="#ffffc0">
                            <asp:Button id="GeneralUpdateButton" text="Submit Application" commandname="Insert" runat="server" SkinID="Btn-8" />
                            </td>
                        </tr>
                        <tr><td colspan="2" style="height: 30px" bgcolor="#ffffc0"><strong><span style="text-decoration: underline">Attendance Support Form</span></strong></td></tr>
                        <tr>
                            <th style="text-align: left">Date (mm/dd/yyyy) </th>
                            <td><asp:TextBox ID="txt_Date" runat="server" Text='<%# Bind("Att_Date") %>' /> </td>
                        </tr>
                        <tr>
                            <th style="text-align: left">Time in (HH:MIN)</th>
                            <td><asp:TextBox ID="txt_TimeIn" runat="server" Text='<%# Bind("TimeIn") %>' /></td>
                        </tr>
                        <tr>
                            <th style="text-align: left">Time Out (HH:MIN)</th>
                            <td><asp:TextBox ID="txt_TimeOut" runat="server" Text='<%# Bind("TimeOut") %>' /></td>
                        </tr>
                        <tr>
                            <th style="text-align: left">Reason for not sliding my staff curd</th>
                            <td><asp:RadioButtonList ID="rbtnlst_Reason" runat="server" AutoPostBack="false">
                                     <asp:ListItem Text = "new staff - first day of report duty" Value ="0" />                       
                                     <asp:ListItem Text = "forgot to bring staff card." Value ="1" />                       
                                     <asp:ListItem Text = "forgot to clock in and/or out." Value ="2" />
                                     <asp:ListItem Text = "outdoor work in Hong Kong or PRC." Value ="3" />                       
                                     <asp:ListItem Text = "name of toy fair." Value ="4" />                       
                                     <asp:ListItem Text = "other reason." Value ="5" />
                                </asp:RadioButtonList>

                            </td>
                        </tr>
                          <tr>
                            <th style="text-align: left">Description</th>
                            <td><asp:TextBox ID="txt_Desc" runat="server" Text='<%# Bind("Description") %>'/></td>
                        </tr>
                     </table> 
                </InsertItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="AttendanceRegisterSQL" runat="server"
            ConnectionString="<%$ ConnectionStrings:eLeaveConnectionString %>"
            InsertCommand="INSERT INTO [WEBeLeave]..[eLeave_Attendance]( [StaffNo], [Dept], [Att_Date], [TimeIn], [TimeOut], [Reason], [AppliedBy], [Description], [RegisterStatus])
                            VALUES (@StaffNo,@Dept,@Att_Date,@TimeIn,@TimeOut,@Reason, @AppliedBy,@Description, @RegisterStatus)"
         >
            <InsertParameters>
                   <asp:SessionParameter Name="StaffNo" SessionField="StaffNo" Type="String" />
                   <asp:SessionParameter Name="Dept" SessionField ="Dept"  Type="String"/>
                   <asp:Parameter Name="Att_Date" Type="DateTime" />
                   <asp:Parameter Name="TimeIn" Type="String" Size="5" />
                   <asp:Parameter Name="TimeOut" Type="String" Size="5" />
                   <asp:ControlParameter Name="Reason" ControlID="rbtnlst_Reason" PropertyName="SelectedValue" />                            
                   <asp:SessionParameter Name="AppliedBy" SessionField="StaffNo" Type="String" />
                   <asp:Parameter Name="Description" Type="String" />
                   <asp:Parameter Name="RegisterStatus" Type="String" DefaultValue="pending" />
            </InsertParameters>
        </asp:SqlDataSource>
     
    </asp:Content>

     

  • Re: Problem with using FormView with asp:ControlParameter

    07-08-2008, 12:17 AM
    Answer
    • Participant
      1,278 point Participant
    • niharnayak2003
    • Member since 11-22-2007, 4:59 AM
    • Chennai
    • Posts 243
    Nihar ranjan Nayak
    Microsoft certified Professional
    niharnmayak2003@yahoo.co.uk
    www.webnihar.com
  • Re: Problem with using FormView with asp:ControlParameter

    07-08-2008, 9:17 PM
    • Member
      2 point Member
    • Andrew Chan
    • Member since 07-07-2008, 10:39 PM
    • Hong Kong
    • Posts 6

     Thank you for your help, may i know how to perform client side validation in the page which inherit from a master page. Thanks again~

Page 1 of 1 (3 items)