Adding dynamic info to a gridview

Posts   
 
    
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 07-Jan-2007 22:01:37   

Hi,

Here's a newbie question.

I'm building a web-application for ASPNET 2.0.

I have a gridview showing info retrieved from the database. Now I want to add a seperate collumn having info determined partly by info present in the database, but also partly coming from info from external sources. E.g. file creation / save info of a file on a directory.

In the past (ASPNET 1.0) I used DataGrid and built my own datasources which I binded in page_load and refresed when the page-index changed.

What is an easy way to do using LLBLGEN under ASPNET 2.0?

Regards,

Jan

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-Jan-2007 07:27:48   

One easy way is to use a dataTable as the source of Data, and before binding create a new column and fill it with data.

You can retrieve the data as a TypedList, dynamicList or TypedView, all of them are dataTables.

you can also use a DataTable which is a result of an EntityView projection.

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 08-Jan-2007 08:49:11   

Hi Walaa,

I decided to add a template column to the gridview. Works fine.

Isn't it also possible to add a property to an entity and retreive that property in a llblgenprodatasource?

Regards,

Jan

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-Jan-2007 09:02:46   

Isn't it also possible to add a property to an entity and retreive that property in a llblgenprodatasource?

Yes, sure.

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 08-Jan-2007 09:25:00   

So, just adding a propery to e.g. CustomerEntity would achieve that that property is supplied by the datasource to the gridview? Or do I need to do something extra?

I looked for examples. In http://weblogs.asp.net/fbouma/archive/2006/06/09/LLBLGen-Pro-v2.0-with-ASP.NET-2.0.aspx the properties of a customer entity are extended in Extending the CustomerEntityFactory.

Is that the way to do it?

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 08-Jan-2007 15:10:48   

Hello,

if you add a customproperty to your entity, you will be able to show it on a gridview throught a llblgenpro datasource. You only have to add the column to your grid.

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 08-Jan-2007 22:47:56   

I tried that first, but it did not appear in the list of selectable items. Then I changed to template columns.

After your reaction, I tried it again. When I opened the window where you can pick columns, I saw that the property I added yesterday was in the list. So I removed the templatecolumns and added the property. That worked fine. Than I added another property. It did not appear in the list directly. I saved the application and restarted VS2005 and then it was in the list. Perhaps next time i should close and reopen the aspx screen after having added a property to an entity,

Thanks anyhow. It works great.

Jan

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 09-Jan-2007 15:15:30   

Hello,

Sometimes VS2005 doesn't refresh the data (even with the sp1) so the better way is to close an open again the file.

cheers