Can I put a Grid view in a DataList?

Hello Experts!

I have a DataList that gets data from an Object data source.

  Also within the Data List I want to display a grid which also has a seperate object data source.

 The Data Key of the Datalist's Object Data source has a value that I will use as a FilterExpression for the Grids Object Data Source.

 Using the DataLists 'OnItemDataBound' event handler I get the DataKey of the current record and use it as a filter for the  grids object data source and DataBind the Grids Object data source.  

I got the Grid to display for the First Data list Item Correctly.  However, It is repeated for the whole list and does not display the correct coresponding data key for each row.  

I put a break point  in the 'OnItemDataBound'  event handler and the Correct Key is being filtered and Databound.
However it is repeating the first grid and not updating the grid.

Any Ideas?

Thanks




DataSource  Within the the objectdata source I have a datakey.
nowmbieAsked:
Who is Participating?
 
eguilhermeConnect With a Mentor Commented:
you have 1 gridview inside the datalist correct ?

and this gridview objectdatasource is inside the itemtemplate of the datalist or outside ?

if its outside, then thats why they all repeat.. since they are binding to all gridviews that gets generated..

try addin the objectdatasource of the grdiview inside the datalist itemtemplate
0
 
nowmbieAuthor Commented:
Great, Then How do I access the ObjectDataSource in code behind?  


I am getting "ObjDataS does not exist in current context".

My DataList id = DL.  

Thanks !

0
 
nowmbieAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.