当我单击日历时,日期应显示在下拉菜单中 [英] when i click the calendar that date should be displayed in DropDown

查看:77
本文介绍了当我单击日历时,日期应显示在下拉菜单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字段下拉列表.

出生日期下拉列表

日历

当我单击日历时应该显示该日期.(无论单击哪个日期,我都应该在下拉列表中显示该日期.)

i have one field dropdown.

Date of birth Dropdown

Calendar

when i click the calendar that date should be displayed.(Whichever date i click that date should be displayed in dropdown).

推荐答案

我无法确定您确切想要的内容请提供详细的要求.
I cant determine what you Exactly want to do..Please Provide Detailed Requirement what the exact situation is.


我想您在找这个
吗?
在您的aspx页面中

May I think your looking for this

In your aspx page

<asp:Calendar ID="Calendar1" runat="server"

    onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>
    <asp:DropDownList ID="DropDownList1" runat="server">
        <asp:ListItem>1</asp:ListItem>
        <asp:ListItem>2</asp:ListItem>
        <asp:ListItem>3</asp:ListItem>
        <asp:ListItem>4</asp:ListItem>
        <asp:ListItem>5</asp:ListItem>
        <asp:ListItem>6</asp:ListItem>
        <asp:ListItem>7</asp:ListItem>
        <asp:ListItem>8</asp:ListItem>
        <asp:ListItem>9</asp:ListItem>
        <asp:ListItem>10</asp:ListItem>
        <asp:ListItem>11</asp:ListItem>
        <asp:ListItem>12</asp:ListItem>
        <asp:ListItem>13</asp:ListItem>
        <asp:ListItem>14</asp:ListItem>
        <asp:ListItem>15</asp:ListItem>
        <asp:ListItem>16</asp:ListItem>
        <asp:ListItem>17</asp:ListItem>
        <asp:ListItem>18</asp:ListItem>
        <asp:ListItem>19</asp:ListItem>
        <asp:ListItem>20</asp:ListItem>
        <asp:ListItem>21</asp:ListItem>
        <asp:ListItem>22</asp:ListItem>
        <asp:ListItem>23</asp:ListItem>
        <asp:ListItem>24</asp:ListItem>
        <asp:ListItem>25</asp:ListItem>
        <asp:ListItem>26</asp:ListItem>
        <asp:ListItem>27</asp:ListItem>
        <asp:ListItem>28</asp:ListItem>
        <asp:ListItem>29</asp:ListItem>
        <asp:ListItem>30</asp:ListItem>
        <asp:ListItem>31</asp:ListItem>
        <asp:ListItem></asp:ListItem>
    </asp:DropDownList>



在DropDownlist的Items Collection属性中添加日期.日期只能是静态的,即最多31个

在您的aspx.cs页面中



Add dates in Items Collection property of DropDownlist. Dates will be static only i.e. 31 max.

in you aspx.cs page

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        DateTime dt = Calendar1.SelectedDate;
        DropDownList1.SelectedValue = dt.Date.ToString("dd");
    }


尝试一下,
Try this,
ddlfieldnames.Items.Clear();
       ddlfieldnames.Items.Add(calender.SelectedDate.ToString());


这篇关于当我单击日历时,日期应显示在下拉菜单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆