I need to efficiently display a large amount of data in a GridView. Due to the abundance of information in each row, I am looking for a way to show additional details when a user clicks on a specific row. The PopupExtender from the AJAX Toolkit seems like the perfect solution for this case.
My goal is to have the popup appear whenever any control within the row is selected. While I have successfully attached the PopupExtender to a single control within the row, I am facing difficulties attaching it to the entire row itself.
I attempted to set the PopupExtender's TargetControlId
to the Row's ClientID during the RowDataBound event, but encountered a runtime error:
TargetControlID of 'popupExtId' is not valid.
A control with ID 'gvList_ctl02' could not be found.
I noticed that the rendered GridViewRow's tr element does not include an id attribute. To address this, I extended the GridView control by overriding the CreateRow
method to render the row's ID (e.g. gvList_ctl02). However, even after making these changes, I continued to face the same runtime error when reintroducing the PopupExtender into the code.
I also attempted to bind the showPopup() javascript command to the row's onclick
event to manually trigger the popup display. Despite successfully registering the click event and triggering it, the popup still did not appear.
Is there a way to properly bind a PopupExtender to a GridViewRow?
This is my current row bound code:
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Bind the popup extender's target ID to the row ID
// This attempt results in a runtime error
PopupControlExtender pop = e.Row.FindControl("popupExtId") as PopupControlExtender;
pop.TargetControlID = e.Row.ClientID;
// Attempt to bind the client-side click handler to show the popup
// The alert is triggered without a javascript error, yet the popup remains hidden
e.Row.Attributes.Add("onclick", "alert('Row Clicked'); $find('" + pop.BehaviorID + "').showPopup();");
}
}
Thank you for any insight or assistance.