设置模板列中Calendar控件的属性
protected void Calendar3_Init(object sender, EventArgs e)
{
Calendar cd = (Calendar)(DetailsView1.FindControl("Calendar3"));//找到要设置的控件
cd.SelectedDate = DateTime.Today;
}
在模板列中加入Button并获得所点击Button所在的Row
<asp:TemplateField HeaderText="转到此天">
<ItemTemplate>
<asp:Button ID="Button2" runat="server" CausesValidation="False" CommandArgument='<%# Bind("WorkDate", "{0}") %>'
CommandName="ToTheDay" Text="转到此天" Font-Bold="False" Font-Names="微软雅黑" Width="83px" />
</ItemTemplate>
</asp:TemplateField>
protected void GridViewWorkUncompleted_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ToTheDay")//当按钮的CommandName为"ToTheDay"时,将绑定的CommandArgument值转换成Calendar1的SelectedDate
{
Calendar1.SelectedDate= DateTime.Parse(e.CommandArgument.ToString());
Calendar cd = (Calendar)(DetailsView1.FindControl("Calendar3"));//找到要设置的控件
cd.SelectedDate = Calendar1.SelectedDate;//改变Calendar3的选择日期
}
}
posted on 2008-12-30 14:56
zh23j_emu 阅读(402)
评论(0) 编辑 收藏 引用