两个问题 第一个
string id=request.querystring( "id ");
非常郁闷,如果传递id参数那么就不出现错误,如果没有传递过来参数马上就提示错误。。很郁闷,,,(asp里是如果接受不到id的话就id= " ",结果asp.net里刚执行到request.querystring( "id ");就出错,,请问有什么办法让他接受不到的话就让id= " "呢?)
第二个问题;
DataTime.Now.tostring();获取的是日期+时间,怎么样才能获取日期不要时间啊例如“2007-01-01”
------解决方案--------------------------------------------------------
if(Request.QueryString[ "id "]!=null)
{
string s=Request> QuertString[id].tostring();
}
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
string id;
if(request.querystring( "id ")!=null)
{
id=request.querystring( "id ");
}
------解决方案--------------------------------------------------------
第2题DataTime.Now.tostring( "yyyy-MM-dd ");
------解决方案--------------------------------------------------------
我记得是用中括号吧?
string id= " ";
if(Request.QueryString[ "Id "]!=null)
id=Request.QueryString[ "Id "];
------解决方案--------------------------------------------------------
string UserID = string.Empty;
if(Request.QueryString[ "UserID "]!=null)
{
UserID = Request.QueryString[ "UserID "].ToString();
}
------解决方案--------------------------------------------------------
DataTime.Now.ToString( "yyyy-MM-dd ")
------解决方案--------------------------------------------------------
string id = string.Empty;
id = Request.QueryString[ "id "];
//----------------
string thedate = DateTime.Now.Date;
//或者这样
string thedate = DateTime.Now.Year + "- " + DateTime.Now.Date.Month + "- " + DateTime.Now.Day;
//很简单吧?!
------解决方案--------------------------------------------------------
DataTime.Now.ToLongDateString();
------解决方案--------------------------------------------------------
问题二:
从数据库取出来时转换
select top 6 id,title,Utter_Date_1=CONVERT(char(10),Utter_Date,20),Is_Pic_News,Miniature_Src from News where issue=1 and Sort= '3 ' and Small_Sort= '9 ' and roll_vertical = 1 and Miniature_Src <> ' 'order by num asc,Utter_Date desc,Id desc;
------解决方案--------------------------------------------------------
DateTime.Now.ToShortDateString()
------解决方案--------------------------------------------------------
抢得真是快啊。。。无语
------解决方案--------------------------------------------------------
楼主不要急..休息一下,休息一下
------解决方案--------------------------------------------------------
问题1:用if判断下就可以
string UserID = string.Empty;
if(Request.QueryString[ "UserID "]!=null)
{
UserID = Request.QueryString[ "UserID "].ToString();
}
问题2:datetime.now.date 可以取得2007-01-01