计算中间日期并在gridview中显示它(calculate inbetween date and show it in gridview)

   IT问题网   2021-01-19 00:00:00

问 题

你好朋友,



使用日期时间选择器我得到两天如12/12/2011和15/12/2011我想得到inbetween日期

 gridview 
喜欢



 13/12/2011 
14 / 12/2011
15/12/2011

解决方案

 datetime fromdate =  new  datetime( 2011  12  12 ); 
datetime todate = new datetime( 2011 12 15 );

var alldates = enumerable.range( 1 ,todate.subtract(fromdate ).days)。选择(i = gt; fromdate.adddays(i));


分配这个alldates到datagridview数据源。

我假设你从两个datetimepickers获得开始和结束日期,所以我会做这样的事情:



 datetime startdate = dtpstart.value; 
datetime enddate = dtpend.value;
int numberofdays =(enddate-startdate).days;
listlt; datetimegt; days = new 列表lt; datetimegt;();
for int i = 1 ; i lt; = numberofdays; i ++)
{
days.add(startdate.adddays(i));
}




这会给你一个listlt; datetimegt;中间的所有日子,不包括你的例子中的开始日期。



希望这有帮助

看看

http://forums.asp.net/p/1114949/1740647.aspx[ ^ ]

http://geekswithblogs.net /dotnetvinz/archive/2009/05/07/filter-gridview-data-based-from-date-ranges.aspx[ ^ ]

标签:计算中间日期显示



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

为它的学生项目(Project for an it student)

problem hi, i m an bsc it student ,as many of you will kn ...

单击更改图标通知(Change Icon Notify on Click)

problem is possible changer notifyicon1 on click the prog ...

如果用户已经登录,则在同一浏览器中重定向到主页asp .net c#(Redirect to Home page if user already logged in, in same browser asp .net c#)

problem i want to make application that if user in logged ...

需要帮助来使用MySqlTransaction(Need help in using MySqlTransaction)

problem hi all i would like to use mysqltransaction in my ...

如何使用VBscript导航Windows注册表树(How to navigate Windows registry tree with VBscript)

problem does anyone know how to go about navigating the w ...

silverlight内存泄漏(silverlight memory leak)

problem hi, i was creating a dependencyproperty changed w ...

如何在json中获取单个元素(How to get single element in json)

problem in wcf service i am getting json response in that ...

双击文件打开程序,如何在c#中实现(double click on file opens program, how to implement in c#)

problem usually when a program in installed, you can clic ...

如何在我添加的现有数据表中添加新列,但它是bofore行的结尾(how add new column in existing datatable i added but its is come end of the bofore rows)

problem my datatable contans two columns id value ----- ...

如何在c#.net中的现有页面中打开新网址(How to open new url in existing page in c#.net)

problem hi to all, this is mdsiddiqali.i added new page n ...

DeleteObject方法不会删除任何内容 - 请帮忙。(DeleteObject method doesn't delete anything - please help.)

problem hello. i am trying to create method that will del ...

项目模板类型在C#中使用?(PROJECT TEMPLATE TYPE TO USE IN C#)

problem edit; okay i am creating a dock for programs to r ...

如何在我添加的现有数据表中添加新列,但它是bofore行的结尾(how add new column in existing datatable i added but its is come end of the bofore rows)

problem my datatable contans two columns ; id value ---- ...

在c#和asp.net中使用LinkedIn API?(Working with LinkedIn APIs in c# and asp.net )

problem hey i was trying to design an asp.net based webs ...

设计模式的案例研究(Case Studies for Design Pattern)

problem hi everyone, though i found "design patterns exp ...

返回所有组件(Retur all components)

problem dears, i need a method to return all named contro ...

Picturebox控件不会触发鼠标事件(Picturebox control not firing mouse events)

problem i have a picturebox control in a groupbox control ...

Windows 7中的VB.net + Crystall报告问题(VB.net + Crystall report issue in Windows 7)

problem i have created windows application in vb.net 2005 ...

如何将数据表中的数据保存回数据库?(How to save the data in a datatable back into the database)

problem i have filled my datatable with my sqladapter ass ...

测试ip和developpe ip扫描仪(Test ip and developpe ip scanner)

problem hi friends, i want help !!! i need c ...