dagagrid选择日期模板列问题,请大家帮忙
总是类型转换错误aspx页引用日期控件
<%@ Register TagPrefix="cc1" Namespace="Nomagic.Web.UI.WebControls" Assembly="Nomagic.Web.UI.WebControls" %>
<asp:TemplateColumn HeaderText="取消日期">
<ItemTemplate>
<FONT face="宋体">
<asp:Label id="Label3" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "qxrq") %>'>
</asp:Label></FONT>
</ItemTemplate>
<EditItemTemplate>
<FONT face="宋体">
<cc1:calendar id="calendar1" runat="server" ScriptPath="../script/"></cc1:calendar></FONT>
</EditItemTemplate>
cs文件中
protected void ListsGrid_Update(object sender, DataGridCommandEventArgs e)
{
if(Page.IsValid)
{
Calendar cale = (Calendar)(this.ListsGrid.Items[e.Item.ItemIndex].FindControl( "Calendar1"));
ListsGrid.EditItemIndex = -1;
BindGrid();
}
}
这一句
Calendar cale = (Calendar)(this.ListsGrid.Items[e.Item.ItemIndex].FindControl( "Calendar1"));
总是提示类型转换无效我该怎么写啊,高手求救啊!!!!!!!!!!!!!!
--------------------编程问答-------------------- up --------------------编程问答-------------------- 试试:
Calendar cale = this.ListsGrid.Items[e.Item.ItemIndex].FindControl("Calendar1") as Calendar;--------------------编程问答-------------------- Calendar cale = this.ListsGrid.Items[e.Item.ItemIndex].FindControl("Calendar1") as Calendar; --------------------编程问答-------------------- 无法强制转换为Calendar --------------------编程问答-------------------- 先感谢上面朋友,转换不出错了,可是我下面语句提示未将对象引用到实例!难道我这样转换是错误的,应该如何写呢!
cale.SelectedDate.ToShortDateString(); --------------------编程问答-------------------- if((Calendar)(this.ListsGrid.Items[e.Item.ItemIndex].FindControl( "Calendar1"));
!=null)
{
Calendar cale = (Calendar)(this.ListsGrid.Items[e.Item.ItemIndex].FindControl( "Calendar1"));
}
补充:.NET技术 , ASP.NET