开发者

Binding the selected value in ASP datepicker to formview in ASP.NET

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 Pick开发者_运维百科er</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.


Make your input control a server control by adding runat="server" to the control, and then use value property.

<input type="text" runat="server" value='<%# Bind("dateborrowed") %>' name="dateborrowedTextBox" readonly id="dateborrowedTextBox">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜