views:

25

answers:

1

This is how i have it setup:

DAL: a dbml file for the context BLL: All my BL rules Types: I made type for every object that i return to my presentation layer.

Now that i made types and use this structure i find it hard to understand how to manipulate data. Normally i could just bind my datacontext to a grid and just activate all the datagrid's possibilities without having to worry about anything. Now for example when i want to enable sorting, i have to write my own logic to return teh right rows to the grid etc.

I have a multiview with two datagrids. The first datagrid is an overview grid and has an option to select an entry. When i select the entry i switch to my second view and I want to show the details for the selected object there. However... I bound a List to the first grid and now I don't know how to find out what entry is selected. I have an event handler for the SelectedIndexChanged. I want to catch the right details for the 2nd datagrid there.

+1  A: 

Hello, assuming that your objects from the BLL have an Id property, apply a the name of the property as a datakey to the first GridView. In the aspx page, add the following property to the gridview

DataKeyNames="Id"

On the SelectedIndexChanged, get the Id of your selected object using the following code:

string id = myGrid.SelectedDataKey.Value;

Now that you have your Id, you can query your needed object from the DB.

SiN
I'll try and be very thanksful if it will work :)
Younes
It worked ;), thanks alot!
Younes