Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello. I have a gridView that shows my data.
for to fill girdview ,I use entity framework.

C#
myGridView.DataSource = db.Books.ToList();

I have a column in my database that has datetime type.
because datetime type in sql server not support solar date,
i want when i get data from database convert it to solar date and then show it in my gridView
but above code don't work for this. and so i used down code but this encounter to error :

C#
var query = from book in db.Books
	    select new (libraryString.ConvrtToSolarDate(RegisterDate),...,...,...); 

(libraryString is a class that i wrote for convert to solar date)
can anybody help me?

(execuse me for my poor english)
Posted

There is one event of Gridview i.e. RowDataBound. You can do all your action here, this will execute before loading the Gridview.
 
Share this answer
 
Comments
Praveen Kumar Upadhyay 16-Mar-15 4:03am    
Great. You have accepted solution then undo it and again accepted.
Thanks bdw.
I found another way for that :
C#
var query = from book in db.Books
            select book;
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("RegisterDate");
foreach (var item in query)
{
        dt.Rows.Add(item.Name,
        LibString.ConvrtToSolarDate(item.RegisterDate));
}
myDataGridView.DataSource = dt;
 
Share this answer
 

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