dropdownlist控件使用问题。
怎么在DropDownList2_SelectedIndexChanged事件中获取DropDownList1_SelectedIndexChanged中的isRunNi...
怎么在DropDownList2_SelectedIndexChanged事件中获取DropDownList1_SelectedIndexChanged中的isRunNian属性啊?如果isRunNian为真的话,当月份是二月的时候daysOfMonth就赋值为29.请大神帮帮忙!!
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Boolean isRunNian = false;
int year = (int)(Convert.ToInt32(DropDownList1.SelectedItem.Value.ToString()));
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
isRunNian = true;
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
int daysOfMonth;
int month = (int)(Convert.ToInt32(DropDownList2.SelectedItem.Value.ToString())); ;
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month ==12)
daysOfMonth = 31;
else if (month == 2)
{
if(DropDownList1_SelectedIndexChanged().isRunNian==true)
}
} 展开
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Boolean isRunNian = false;
int year = (int)(Convert.ToInt32(DropDownList1.SelectedItem.Value.ToString()));
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
isRunNian = true;
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
int daysOfMonth;
int month = (int)(Convert.ToInt32(DropDownList2.SelectedItem.Value.ToString())); ;
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month ==12)
daysOfMonth = 31;
else if (month == 2)
{
if(DropDownList1_SelectedIndexChanged().isRunNian==true)
}
} 展开
2个回答
展开全部
你可以把isRunNian设为全局的变量啊,写到这两个事件函数的外面。
private boolean isRunNian = false; //移到到外面来
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
int year = (int)(Convert.ToInt32(DropDownList1.SelectedItem.Value.ToString()));
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
isRunNian = true;
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
int daysOfMonth;
int month = (int)(Convert.ToInt32(DropDownList2.SelectedItem.Value.ToString())); ;
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month ==12)
daysOfMonth = 31;
else if (month == 2)
{
if(isRunNian) //这里判断
daysOfMonth = 29;
}
}
希望能帮到你 : )
展开全部
把Boolean isRunNian当做一个字段或属性,DropDownList2_SelectedIndexChanged就可以获取了
追问
哦,我也是这样想的,但是DropDownList1_SelectedIndexChanged()括号里面的东西怎么写呢?
追答
括号里面写
DropDownList1_SelectedIndexChanged(null,null)
或者DropDownList1_SelectedIndexChanged(sender,e)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询