Calendar控件问题
我在Calendar中选定日期后,把选中的日期赋给TextBox控件,可选后却出现:“
未将对象引用设置到对象的实例。” 的错误。球解。。代码如下:
CS:
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox TGDate2 = (TextBox)FormView1.FindControl( "TGDate ");
Calendar Calendar2 = (Calendar)FormView1.FindControl( "Calendar ");
TGDate2.Text = Calendar2.SelectedDate.ToString( "yyyy-MM-dd ");
}
aspx:
<asp:TextBox ID= "TGDate " runat= "server " Text= ' <%# Bind( "ChanDi ") %> '> </asp:TextBox>
<asp:Calendar ID= "Calendar1 " runat= "server " BackColor= "#FFFFCC " BorderColor= "#FFCC66 "
BorderWidth= "1px " DayNameFormat= "Shortest " Font-Names= "Verdana " Font-Size= "8pt "
ForeColor= "#663399 " Height= "200px " OnSelectionChanged= "Calendar1_SelectionChanged "
ShowGridLines= "True " Width= "220px ">
<SelectedDayStyle BackColor= "#CCCCFF " Font-Bold= "True " />
<TodayDayStyle BackColor= "#FFCC66 " ForeColor= "White " />
<SelectorStyle BackColor= "#FFCC66 " />