关于gridview绑定datetime的问题
gridview绑定datetime,出来的结果是:2012-6-8 0:00:00 新增更新信息
现在我不想要那个时分秒,请教高手怎么办?
绑定代码如下:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bind();
}
}
public SqlConnection GetConnection()
{
string myStr = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection myConn = new SqlConnection(myStr);
return myConn;
}
protected void bind()
{
SqlConnection myConn = GetConnection();
myConn.Open();
string sqlStr = "select * from [update] ";
SqlDataAdapter myDa = new SqlDataAdapter(sqlStr, myConn);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
GridView1.DataSource = myDs;
GridView1.DataBind();
myDa.Dispose();
myDs.Dispose();
myConn.Close();
}
------解决方案--------------------
GridView1_RowDataBound事件中处理
C# code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[日期列索引].Text = 格式化字符串;
}
}