在C#ASP.net中显示月份 [英] Display Months in C# ASP.net

查看:76
本文介绍了在C#ASP.net中显示月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想在我的网站(C#asp.net)的报告中显示月份

i有两个下拉列表从月份到月份





假设从选定月份开始 - 2012年11月

假设选择月份是 - 2013年12月





现在我必须在报告中显示 - 11月| 12月| 1月作为列

解决方案

如果您存储月份的变量是DateTime变量,那么它非常简单,因为您只需将其转换为字符串并在字符串中设置参数实现您的首选格式:



  //  假设变量fromDate是DateTime变量 
fromDate.toString( MM ); // 返回编号为月的字符串
fromDate.toString( MMMM); // 返回包含月份的字符串,例如:11月


Hi All,

I want to display months in reports in my website (C# asp.net)
i have two dropdownlist for from month and to month


Suppose From month selected is- November 2012
Suppose To month selected is- December 2013


now i have to display in reports- November|December|January as columns

解决方案

If the variable you are storing your months is DateTime variable, then its really simple because all you have to do is convert it to string and set the parameters in the string to achieve your preferred format:

//Assuming variable fromDate is DateTime variable
fromDate.toString("MM"); // returns a string with numbered month
fromDate.toString("MMMM"); // returns a string with month in words like: November


这篇关于在C#ASP.net中显示月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆