C# 将ASP日期选择器中的选定值绑定到ASP.NET中的formview
我有一个弹出式日期选择器,可以将选定的日期插入文本框。我的问题是无法将其绑定到asp.net textbox控件。我目前正在跟踪,但它显示了一个错误“当前上下文中不存在名称'dateborrowedTextBox'。我希望它将所选值绑定到formview中的文本框,以便将其添加到数据库中 下面是我的formview控件插入示例C# 将ASP日期选择器中的选定值绑定到ASP.NET中的formview,c#,asp.net,data-binding,formview,C#,Asp.net,Data Binding,Formview,我有一个弹出式日期选择器,可以将选定的日期插入文本框。我的问题是无法将其绑定到asp.net textbox控件。我目前正在跟踪,但它显示了一个错误“当前上下文中不存在名称'dateborrowedTextBox'。我希望它将所选值绑定到formview中的文本框,以便将其添加到数据库中 下面是我的formview控件插入示例 <InsertItemTemplate> Book Title: <asp:DropDownList I
<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>
书名:
非常感谢您的帮助。
提前感谢。通过向控件添加
runat=“server”
将您的输入控件设置为服务器控件,然后使用值属性
<input type="text" runat="server" value='<%# Bind("dateborrowed") %>' name="dateborrowedTextBox" readonly id="dateborrowedTextBox">
谢谢!它工作了,但仍然有一个bug。错误:“this.\u targetEl.value.length”为空或不是对象。我认为这与上述解决方案不同。这是我的解决方案实施后您遇到的问题吗?是的。我不把它们绑在一起就没问题了。我认为我有一些错误。我会顺便问一下,有没有办法让我得到这个值?我的意思是,在输入类型=文本中,如何获取值并将其传递给asp:TextBox((System.Web.UI.HtmlControl.HtmlInputText)detailsView1.FindControl(“dateborrowedTextBox”)).value