Click here to Skip to main content
14,930,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, i want to change my datetime in the grid view to shortdatatype throw data bound any suggestions !!??
Posted

1 solution

Yes... so what is the problem ?

void GridView_RowDataBound(object sender, 
  GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        TextBox tb = e.Row.FindControl("tb") as TextBox;
        tb.Text = DateTime.Parse(DataBinder.Eval(e.Row.DataItem,"Date").ToString()).ToShortDateString();
        
    }
}


You might change it according to your need. Rather than Parse you might use ParseExact as well if you know the exact format.

Hope you got it. ;) :thumbsup:
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900