将 ASP datepicker 中的选定值绑定到 ASP.NET 中的 formview
我有一个弹出日期选择器,它将选定的日期插入文本框。我的问题是我无法将其绑定到 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>
我们将不胜感激。 提前致谢。
I have a pop up date picker which insert a selected date into a textbox. My problem is that I cannot bind it to the asp.net textbox control. I'm currently following this but it shows an error "The name 'dateborrowedTextBox' does not exist in the current context". I want it to bind the selected value to a textbox in formview so I can add it to the database.
Here's a sample of my formview control Insert
<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>
Help would be much appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过向控件添加
runat="server"
使输入控件成为服务器控件,然后使用value 属性
。Make your input control a server control by adding
runat="server"
to the control, and then usevalue property
.