最大值和最小值文本框的范围验证器最短日期不起作用?
我在页面加载中使用以下代码,但它给出错误:
无法隐式转换类型
System.DateTime
到string
所以我已经将 RangeValidators 类型更改为字符串;但它不起作用,我希望该文本框应包含 max 和 之间的日期运行时指定的最小值?
yr1 =Convert.ToString(Session["FYear"]);
yr=yr1.Split('-');
startyr = yr[0].ToString();
endyr = yr[1].ToString();
dt1 = "01/04/" + startyr;
dt2 = "31/03/" + endyr;
RangeValidator1.MinimumValue =Convert.ToDateTime(dt1);
RangeValidator1.MaximumValue = Convert.ToDateTime(dt2);
I am using following code in page load but it give Error:
Cannot implicitly convert type
System.DateTime
tostring
so i have change RangeValidators type to string; but its not working, I want that textbox should contain date between max & min value specified at runtime?
yr1 =Convert.ToString(Session["FYear"]);
yr=yr1.Split('-');
startyr = yr[0].ToString();
endyr = yr[1].ToString();
dt1 = "01/04/" + startyr;
dt2 = "31/03/" + endyr;
RangeValidator1.MinimumValue =Convert.ToDateTime(dt1);
RangeValidator1.MaximumValue = Convert.ToDateTime(dt2);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RangeValidator
的MinimumValue
和MaximumValue
的类型为System.String
。这就是您收到错误的原因。编辑代码:
了解 RangeValidator
RangeValidator
'sMinimumValue
andMaximumValue
are of the typeSystem.String
. That's why you are getting the error.Edit your code:
Read about RangeValidator