Link to home
Start Free TrialLog in
Avatar of ShaePNC
ShaePNC

asked on

A Call To Bind

I am new at ASP.NET and I was writing some code an tried to compile it and got the following error:

ASP.NET runtime error: A call to Bind must be assigned to a property of a control inside a template.	

I am using Visual Studio 2010, this is the code that generated the message:

<td valign="middle" align="left">ucl:Domain ID="Class_ID" runat="server" DomainName="doll_Courses" ValidatorDisplay="Static" IncludeBlankRow="true" SortColumn="SORT_ORDER" DispCol="WithCode" DomainValue='<%# Bind("Class_ID")%>' IsRequired="True" DisplayMode="Textbox" TextColumns="75" /></td>

That line of code is included in the code below:

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" runat="Server">
    <asp:MultiView ID="mvSurveyInformation" runat="server" ActiveViewIndex="0">
        <asp:View ID="vSurveyInformation" runat="server">
            <asp:FormView ID="fvSurveyInformation" runat="server" Width="100%">
                <EditItemTemplate>
                    <asp:Panel ID="pnSurveyInformation" runat="server" DefaultButton="lbtnUpdate">
                        <div class="command-panel-edit" style="text-align: left">
                            <asp:ImageButton ID="lbtnUpdate" runat="server" AlternateText="Update" CausesValidation="True" CommandName="Update" ImageUrl="~/Images/SAVEITEM.GIF" ToolTip="Save record" />
                            <asp:ImageButton ID="lbtnCancel" runat="server" AlternateText="Cancel" CausesValidation="False" CommandName="Cancel" ImageUrl="~/Images/UNDO.GIF" ToolTip="Cancel Current Operation" />
                            <asp:ImageButton ID="lbtnDelete" runat="server" AlternateText="Delete" CausesValidation="false" CommandName="Delete" ImageUrl="~/Images/delete.gif" ToolTip="Delete record" />
                            <asp:ImageButton ID="lbtnNew" runat="server" AlternateText="New" CausesValidation="false" CommandName="New" ImageUrl="~/Images/additem.gif" ToolTip="Create New Record" />
                            <ajaxToolkit:ConfirmButtonExtender ID="CB_Delete" runat="server" TargetControlID="lbtnDelete" ConfirmText="Delete this?" />
                            <ajaxToolkit:ConfirmButtonExtender ID="CB_Cancel" runat="server" TargetControlID="lbtnCancel" ConfirmText="Cancel and lose All your changes?" />
                            <ajaxToolkit:ConfirmButtonExtender ID="CB_New" runat="server" TargetControlID="lbtnNew" ConfirmText="Start creating a new record?" />
                        </div>
                        <div style="float: right"></div>
                        <div class="clear">
                            <asp:Label ID="DTEMODIFIED" runat="server" Text='<%# Bind("DTEMODIFIED") %>'></asp:Label>
                            <asp:Label ID="Event_ID" runat="server" Text='<%#Bind("Event_ID") %>'></asp:Label>
                        </div>
                        <div align="center">
                            <table id="tblEdit" cellpadding="2" cellspacing="2" border="0" width="100%" align="center">
                                <tr>
                                    <td valign="middle" align="right"><asp:Label ID="lblSurvey" runat="server" Text="Survey"></asp:Label></td>
                                    <td valign="middle" align="left"><asp:DropDownList ID="Survey_ID" runat="server"></asp:DropDownList></td>
                                </tr>
                                <tr>
                                    <td valign="middle" align="right"><asp:Label ID="lblCourseClass" runat="server" Text="Course/Class"></asp:Label></td>
                                    <td valign="middle" align="left">ucl:Domain ID="Class_ID" runat="server" DomainName="doll_Courses" ValidatorDisplay="Static" IncludeBlankRow="true" SortColumn="SORT_ORDER" DispCol="WithCode" DomainValue='<%# Bind("Class_ID")%>' IsRequired="True" DisplayMode="Textbox" TextColumns="75" /></td>
                                </tr>
                                <tr>
                                    <td valign="middle" align="right"><asp:Label ID="lblScheduled" runat="server" Text="Scheduled"></asp:Label></td>
                                    <td valign="middle" align="left"><asp:TextBox ID="SCHEDULED" runat="server" Text='<%#Bind("Scheduled") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td valign="middle" align="right"><asp:Label ID="lblAttended" runat="server" Text="Attended"></asp:Label></td>
                                    <td valign="middle" align="left"><asp:TextBox ID="Attended" runat="server" Text='<%#Bind("Attended") %>'></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td valign="middle" align="right"><asp:Label ID="lblPOC" runat="server" Text="POC"></asp:Label></td>
                                    <td valign="middle" align="left"><asp:TextBox ID="POC" runat="server" Text='<%#Bind("POC") %>'></asp:TextBox></td>                              
                                </tr>
                                <tr>
                                    <td valign="middle" align="right"><asp:Label ID="lblComments" runat="server" Text="Comments"></asp:Label></td>
                                    <td valign="middle" align="left"><asp:TextBox ID="Comments" runat="server" TextMode="MultiLine" Text='<%#Bind("Comments") %>' ToolTip="Enter any comments associated with this survey." Columns="75"></asp:TextBox></td>
                                </tr>
                            </table>
                        </div>
                    </asp:Panel>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Panel ID="droppnlOptions" runat="server" DefaultButton="lbtnEdit">
                        <div class="command-panel">
                            <div style="float: left">
                                <asp:ImageButton ID="lbtnEdit" runat="server" AlternateText="Delete" CausesValidation="false" CommandName="Edit" ImageUrl="~/Images/edit.gif" ToolTip="Edit record" />
                                <asp:ImageButton ID="lbtnNew" runat="server" AlternateText="New" CausesValidation="false" CommandName="New" ImageUrl="~/Images/additem.gif" ToolTip="Create New Record" />
                                <asp:ImageButton ID="lbtnDelete" runat="server" AlternateText="Delete" CausesValidation="false" CommandName="Delete" ImageUrl="~/Images/delete.gif" ToolTip="Delete record" />
                                <ajaxToolkit:ConfirmButtonExtender ID="CB_Delete" runat="server" TargetControlID="lbtnDelete" ConfirmText="Delete this?" />
                                <ajaxToolkit:ConfirmButtonExtender ID="CB_New" runat="server" TargetControlID="lbtnNew" ConfirmText="Start creating a new record?" />
                            </div>
                            <div style="float: right">
                            <asp:HyperLink ID="PrintCourseSummary" runat="server" Text="Print Course Summary" ToolTip="Click here to print a course evaluation summary for this course/class without rating %" ForeColor="White"></asp:HyperLink>
                            ||
                            <asp:HyperLink ID="printCourseSummaryPercentage" runat="server" Text="Print Course Summary %" ToolTip="Click here to print a course evaluation for this course with a rating %" ForeColor="White"></asp:HyperLink>
                            ||
                            <asp:HyperLink ID="printSurveyForm" runat="server" Text="Print Survey Form" ToolTip="Click here to print a survey form for this course/class." ForeColor="White"></asp:HyperLink>
                            </div>
                            <div class="clear"></div>
                        </div>
                        <div align="center">
                        <table id="tblReadOnly" cellspacing="2" cellpadding="2" border="0" align="center">
                            <tr style="display:none">
                                <td><asp:Label ID="lblCanCollect" runat="server" Text='<%# Eval("CAN_COLLECT") %>'></asp:Label></td>
                                <td><asp:Label ID="lblStartON" runat="server" Text='<%#EVAL("START_ON", "{0:MM/dd/yyyy}") %>'></asp:Label></td>
                                <td><asp:Label ID="lblEndON" runat="server" Text='<%#EVAL("END_ON", "{0:MM/dd/yyyy}") %>'></asp:Label></td>
                                <td><asp:Label ID="lblFinishDate" runat="server" Text='<%#EVAL("FINISH_DATE", "{0:MM/dd/yyyy}") %>'></asp:Label></td>
                                <td><asp:Label ID="lblSurveyID" runat="server" Text='<%#EVAL("SURVEY_ID") %>'></asp:Label></td>
                                <td><asp:Label ID="lblEventID" runat="server" Text='<%#EVAL("Event_ID") %>'></asp:Label></td>
                            </tr>
                            <tr>
                                <td valign="middle" align="right"><asp:Label ID="lblStatus" runat="server" Text="Status:" Font-Bold="True"></asp:Label></td>
                                <td valign="middle" align="left" colspan="7"><asp:Label ID="Status" runat="server" Text="Bind to control in FormView_DataBound Event."></asp:Label></td>
                            </tr>
                            <tr><td colspan="8"></td></tr>
                            <tr>
                                <td valign="middle" align="right"><asp:Label ID="lblSurvey" runat="server" Text="Survey:" Font-Bold="True"></asp:Label></td>
                                <td valign="middle" align="left" colspan="7"><asp:Label ID="SURVEY" runat="server" Text='<%# EVAL("SURVEY") %>'></asp:Label></td>
                            </tr>
                            <tr>
                                <td valign="middle" align="right"><asp:Label ID="lblCourseClass" runat="server" Text="Course/Class:" Font-Bold="True"></asp:Label></td>
                                <td valign="middle" align="left" colspan="7"><asp:Label ID="COURSE" runat="server" Text='<%#EVAL ("COURSE") %>'></asp:Label></td>
                            </tr>
                            <tr>
                                <td valign="middle" align="right"><asp:Label ID="lblScheduled" runat="server" Text="Scheduled:" Font-Bold="True"></asp:Label></td>
                                <td valign="middle" align="left" colspan="3"><asp:Label ID="SCHEDULED" runat="server" Text='<%#EVAL("SCHEDULED") %>'></asp:Label></td>
                                <td valign="middle" align="right"><asp:Label ID="lblAttended" runat="server" Text="Attended:" Font-Bold="True"></asp:Label></td>
                                <td valign="middle" align="left" colspan="3"><asp:Label ID="Attended" runat="server" Text='<%#EVAL("Attended") %>'></asp:Label></td>
                            </tr>
                            <tr>
                                <td valign="middle" align="right"><asp:Label ID="lblPOC" runat="server" Text="POC:" Font-Bold="True"></asp:Label></td>
                                <td valign="middle" align="left" colspan="3"><asp:Label ID="POC" runat="server" Text='<%#EVAL("POC") %>'></asp:Label></td>
                                <td valign="middle" align="right"><asp:Label ID="lblOverallScore" runat="server" Text="Overall Score:" Font-Bold="True"></asp:Label></td>
                                <td valign="middle" align="left" colspan="3"><asp:Label ID="OverallScore" runat="server" Text="Still Need to bind this one"></asp:Label></td>                              
                            </tr>
                            <tr>
                                <td valign="middle" align="right"><asp:Label ID="lblComments" runat="server" Text="Comments:" Font-Bold="True"></asp:Label></td>
                                <td valign="middle" align="left" colspan="7"><asp:Label ID="Comments" runat="server" Text='<%#EVAL("COMMENTS") %>'></asp:Label></td>
                            </tr>
                        </table>
                        </div>

I'm not sure if I sshould use %#BIND or %#EVAL because they both give this error message.  Any assistance you can give will be appreciated.
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Does that column exist in the datasource that you bind to formview?
Avatar of ShaePNC
ShaePNC

ASKER

Yes it is.
You are missing the opening < for the ucl:Domain control

<td valign="middle" align="left"><ucl:Domain ID="Class_ID" runat="server" DomainName="doll_Courses" ValidatorDisplay="Static" IncludeBlankRow="true" SortColumn="SORT_ORDER" DispCol="WithCode" DomainValue='<%# Bind("Class_ID")%>' IsRequired="True" DisplayMode="Textbox" TextColumns="75" /></td>
ASKER CERTIFIED SOLUTION
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial