gridvew里My97DatePicker截止时间实现

View Code
 1   protected void GV_GroupPurchasing_RowEditing(object sender, GridViewEditEventArgs e)
 2     {
 3         GV_GroupPurchasing.EditIndex = e.NewEditIndex;
 4         BindData(); 
 5         //这里是不常用的,这是例用了My97DatePicker这个JS控件,使某一列的编辑文本,出现时间控件。  
 6         string sTime = "";
 7         string eTime = "";
 8         int i = e.NewEditIndex;
 9         string rowid =(i+3).ToString();
10         if (int.Parse(rowid) < 10)
11         {
12             sTime = "dnn_ctr596_ucGroupPurchasing_GV_GroupPurchasing_ctl0" + rowid + "_txtStartTime";
13             eTime = "dnn_ctr596_ucGroupPurchasing_GV_GroupPurchasing_ctl0" + rowid + "_txtEndTime";
14         }
15         else
16         { sTime = "dnn_ctr596_ucGroupPurchasing_GV_GroupPurchasing_ctl" + rowid + "_txtStartTime";
17          eTime = "dnn_ctr596_ucGroupPurchasing_GV_GroupPurchasing_ctl" + rowid + "_txtEndTime";
18         }
19 
20 
21         TextBox tbStartTime = (TextBox)GV_GroupPurchasing.Rows[e.NewEditIndex].FindControl("txtStartTime");
22         TextBox tbEndTime = (TextBox)GV_GroupPurchasing.Rows[e.NewEditIndex].FindControl("txtEndTime");
23 
24         tbStartTime.Attributes.Add("onclick", "WdatePicker({maxDate:'#F{$dp.$D("+"\\'"+eTime +"\\'"+")}',dateFmt:'yyyy-MM-dd',isShowClear:true})");
25         tbEndTime.Attributes.Add("onclick", "WdatePicker({minDate:'#F{$dp.$D(" +"\\'" +sTime+ "\\'"+")}',dateFmt:'yyyy-MM-dd',isShowClear:true})");
26        
27      
28      
29     }

 方法二:

fan
protected void GV_CouponCode_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if((e.Row.RowState==(DataControlRowState.Edit|DataControlRowState.Alternate))||e.Row.RowState== DataControlRowState.Edit) { TextBox tbStartTime = e.Row.FindControl("txtStartTime") as TextBox; TextBox tbEndTime = e.Row.FindControl("txtEndTime") as TextBox; //这里是不常用的,这是例用了My97DatePicker这个JS控件,使某一列的编辑文本,出现时间控件。 tbStartTime.Attributes.Add("onclick",
"WdatePicker({maxDate:'#F{$dp.$D(" + "\\'" + tbEndTime.ClientID + "\\'" + ")}',dateFmt:'yyyy-MM-dd',isShowClear:true})"); tbEndTime.Attributes.Add("onclick",
"WdatePicker({minDate:'#F{$dp.$D(" + "\\'" + tbStartTime.ClientID + "\\'" + ")}',dateFmt:'yyyy-MM-dd',isShowClear:true})"); } } }

  

posted @ 2012-05-23 00:41  轻量级程序员  阅读(271)  评论(0编辑  收藏  举报
关注获取博文附件