posts - 26,  comments - 14,  trackbacks - 0
设置模板列中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 阅读(390) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。
<2008年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿(1)

随笔档案

相册

搜索

  •  

最新评论

阅读排行榜

评论排行榜