formview中的datetime picker asp.net

时间:2013-10-06 22:50:32

标签: c# asp.net datetime

我想在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;
    }
}

这样的东西???任何关于smth免费的想法?我想如果有两个litle下拉列表可以提供小时和分钟。但是它可以与日历扩展器一起使用。

0 个答案:

没有答案