This is a migrated thread and some comments may be shown as answers.

Binding data in a DetailTable

1 Answer 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Iggy
Top achievements
Rank 1
Iggy asked on 13 Mar 2009, 07:03 PM
I have a hierarchial grid that displays applications on the top level.  Under each application I display the users for that application.  What I want to do is have the username linked to the page for that user.  I thought it was a fairly simple issue to solve but after a few hours trolling the forums and digging through the documentation I still can't figure out how to accomplish what I need. 

I need to set the NavigateUrl for each user server side because we encrypt the querystring on the URL link to a user.  For a normal grid I simply subscribe to the OnDataBound event for the grid and in that method I get the Hyperlink instance and set it using information from from the row (as seen here).  

I tried subscribing to the OnDataBound event on the DetailTable GridTableView but the event never fires. 
I know this could probably be accomplished by encrypting the data and putting it in the object bound for the detailTable for each user before the databind but I'd rather do it by not modifying the object that I bind to.

Is this possible? 
Thanks.

1 Answer, 1 is accepted

Sort by
0
Craig
Top achievements
Rank 1
answered on 13 Mar 2009, 08:49 PM
You can use the ItemDataBound event of the grid itself.  This fires whenever any of the table views databind on the grid.  So within the function you would check to see which table is binding.  See example below:

protected

 

void grd_ItemDataBound(object sender, GridItemEventArgs e)
{
// Check the name of the table.  (Give your detail tableview a name or you can check which datasource is loading as well)

if

 

(e.Item.OwnerTableView.Name == tableviewname)

 

{
if (e.Item is GridDataItem && !e.Item.IsInEditMode)

 

{
// now you can find your control and set it
e.Item.FindControl("")

etc....

Hope that helps.

Tags
Grid
Asked by
Iggy
Top achievements
Rank 1
Answers by
Craig
Top achievements
Rank 1
Share this question
or