0

我想在 ajax asp:CalendarExtender 中添加时间选择器。我想将 db 列中的选择与 datetime 类型绑定,我的 asp 代码是:

<asp:FormView ID="FormView1" runat="server" AllowPaging="True" OnPreRender="myFormView_PreRender" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource1" GridLines="Horizontal">
    <EditItemTemplate>

        DATE_TIME:

         <asp:TextBox ID="TextBoxDatetime" runat="server" Text='<%# Bind("DATE_TIME") %>' ></asp:TextBox>
        <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBoxDatetime" ></asp:CalendarExtender>


c#代码:

protected void myFormView_PreRender(object sender, EventArgs e)
{
    if (FormView1.CurrentMode == FormViewMode.Edit)
    {
        TextBox txtdate = FormView1.FindControl("TextBoxDatetime") as TextBox;
        DropDownList txthour = FormView1.FindControl("hourddl") as DropDownList;
        DropDownList txtminutes = FormView1.FindControl("MinutesDdl") as DropDownList;
        DropDownList txtpmam = FormView1.FindControl("AMPMddl") as DropDownList;
        string time = string.Format("{0}-{1}{2}", txthour.Text, txtminutes.Text, txtpmam.Text);

        testLabel.Text = time;
    }
}

像这样的东西???有什么免费的想法吗?我认为是否有可能使用两个给出小时和分钟的下拉列表。但是如何使用日历扩展器。

4

0 回答 0