【发布时间】:2011-08-23 22:37:55
【问题描述】:
我有一个弹出日期选择器,可以将选定的日期插入文本框。我的问题是我无法将它绑定到 asp.net 文本框控件。我目前正在关注this,但它显示错误“当前上下文中不存在名称'dateborrowedTextBox'”。我希望它将所选值绑定到 formview 中的文本框,以便我可以将其添加到数据库中。
这是我的表单视图控件插入示例
<InsertItemTemplate>
Book Title:
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="booktitleDataSource" DataTextField="booktitle"
DataValueField="bookid" SelectedValue='<%# Bind("bookid", "{0}") %>'>
</asp:DropDownList>
<asp:SqlDataSource ID="booktitleDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:LibrarySystemConnectionString %>"
SelectCommand="SELECT [bookid], [booktitle] FROM [TblBooks]">
</asp:SqlDataSource>
<br />
Employee PIN:
<asp:TextBox ID="employeeidTextBox" runat="server"
Text='<%# Bind("employeeid") %>' />
<br />
Department:
<asp:TextBox ID="departmentTextBox" runat="server"
Text='<%# Bind("department") %>' />
<br />
<%--I want to the selected value in datepicker to bind it here --%>
Date borrowed:
<asp:TextBox ID="dateborrowedTextBox1" runat="server"
Text='<%# Bind("dateborrowed") %>' />
<%--date picker --%>
<input type="text" name="dateborrowedTextBox" readonly id="dateborrowedTextBox">
<a href="#" onClick="cdp1.showCalendar(this, '<% = dateborrowedTextBox.ClientID %>'); return false;">Date Picker</a>
<br />
<asp:Button ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:Button ID="InsertCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
我们将不胜感激。 提前致谢。
【问题讨论】:
标签: c# asp.net data-binding formview