特定日期数据无法在asp.net页面的gridview中显示 [英] particular date data can't display in gridview at asp.net page

查看:51
本文介绍了特定日期数据无法在asp.net页面的gridview中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Web应用程序并编写代码

i am develop one web application and write the code

SqlConnection con = new SqlConnection("Data Source=NSYS1\\SQLEXPRESS;Initial Catalog=agfl;connect timeout=30;Integrated Security=True");
            con.Open();
            string strQuery = "select * from stf where rdate =@some";
            SqlCommand cmd = new SqlCommand(strQuery, con);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@some", TextBox6.Text);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            gvuser.DataSource = dt;
            gvuser.DataBind();
            con.Close();



但是日期数据无法在gridview中显示我的代码有什么问题


but the date data can't be display in gridview what is problem of my code

推荐答案

select *,convert(varchar(10),rdate,103) as rdate1 from stf where rdate =@some



并在网格视图中将rdate设置为源代码中的rdate1


and in Grid view set rdate to rdate1 in source code


<asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:MMMM d, yyyy}" htmlencode="false" xmlns:asp="#unknown" />





在此处查看



check it here


这里显示所有ok都可以显示你的源代码
here appears all ok can show your source code


这篇关于特定日期数据无法在asp.net页面的gridview中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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