Asp.netPageLoad代码问题

protectedvoidPage_Load(objectsender,EventArgse){ArrayListalYear=newArrayList();ArrayL... protected void Page_Load(object sender, EventArgs e)
{
ArrayList alYear = new ArrayList();
ArrayList alMonth = new ArrayList();
for (int i = 1900; i <= 2014; i++)
alYear.Add(i);
for (int i = 1; i <= 12; i++)
alMonth.Add(i);
if (!this.IsPostBack)
{

ddlYear.DataSource = alYear;
ddlYear.DataBind();
ddlYear.SelectedValue = DateTime.Now.Year.ToString();
ddlMonth.DataSource = alMonth;
ddlMonth.DataBind();
ddlMonth.SelectedValue = DateTime.Now.Month.ToString();
int year = Int32.Parse(ddlYear.SelectedValue);
int month = Int32.Parse(ddlMonth.SelectedValue);
BindDay(year, month);
ddlDay.SelectedValue = DateTime.Now.Day.ToString();
}

gvBorrowList_DataBind();//GridView控件叫gvBorrowList
}

private void BindDay(int year, int month)
{
ArrayList alDay = new ArrayList();
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
for (int i = 1; i <= 31; i++)
alDay.Add(i);
break;
case 2:
if (CheckLeap(year))
{
for (int i = 1; i <= 29; i++)
alDay.Add(i);
}
else
{
for (int i = 1; i <= 28; i++)
alDay.Add(i);
}
break;
case 4:
case 6:
case 9:
case 11:
for (int i = 1; i <= 30; i++)
alDay.Add(i);
break;
}
ddlDay.DataSource = alDay;
ddlDay.DataBind();
}

protected void ddlYear_SelectedIndexChanged(object sender, EventArgs e)
{
int year, month;
year = Int32.Parse(ddlYear.SelectedValue);
month = Int32.Parse(ddlMonth.SelectedValue);
BindDay(year, month);
}
protected void ddlMonth_SelectedIndexChanged(object sender, EventArgs e)
{
int year, month;
year = Int32.Parse(ddlYear.SelectedValue);
month = Int32.Parse(ddlMonth.SelectedValue);
BindDay(year, month);
}
写在PageLoad里的代码是什么意思。我这里面写的是绑定时间的代码,那就是指页面一加 载就绑定时间吗?
展开
 我来答
飞冰鱼1
推荐于2016-10-19 · TA获得超过147个赞
知道小有建树答主
回答量:296
采纳率:80%
帮助的人:147万
展开全部
protected void Page_Load(object sender, EventArgs e)
    {
        ArrayList alYear = new ArrayList();
        ArrayList alMonth = new ArrayList();
        for (int i = 1900; i <= 2014; i++)
            alYear.Add(i);
        for (int i = 1; i <= 12; i++)
            alMonth.Add(i);
            
           //此上是每次加载都执行一次
        if (!this.IsPostBack)
        {
          //此处内的方法 只有第一次加载时执行
         }
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式