I have a gridview and I want to be able to select a row and display it on a detailsview displayed as a modalpopup. However, the details view only shows the first row of the gridview, but if I make the detailsview not to display in a modalpopup, it shows the correct gridview row selection. What am I doing wrong?
<asp:GridView ID="GridView5" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="WorkshopName" DataSourceID="SqlDataSource8" SelectedIndex="0"Width="500px" PageSize="5" onselectedindexchanged="GridView5_SelectedIndexChanged"><Columns><asp:TemplateField ShowHeader="False"><ItemTemplate><asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="Select" ImageUrl="~/Images/Select.png" Text="Select" /><asp:ModalPopupExtender ID="ImageButton1_ModalPopupExtender" runat="server" DynamicServicePath="" Enabled="True" PopupControlID="DetailsView5" TargetControlID="ImageButton1"></asp:ModalPopupExtender></ItemTemplate></asp:TemplateField><asp:DetailsView ID="DetailsView5" runat="server" AutoGenerateRows="False" DataKeyNames="WorkshopName,WorkshopBeginingDate,WorkshopLocation" DataSourceID="SqlDataSource9" Height="50px" Width="330px" GridLines="None" DefaultMode="Edit" BackColor="#CCCCCC" onitemupdated="DetailsView5_ItemUpdated"> protected void DetailsView5_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e) { if (e.Exception != null) { lblerror3.Text = "A database error has ocurred. " + "Message: " + e.Exception.Message; e.ExceptionHandled = true; e.KeepInEditMode = true; } else if (e.AffectedRows == 0) lblerror3.Text = "Another user might have updated that workshop. " + "Please try again."; GridView5.DataBind(); } protected void GridView5_SelectedIndexChanged(object sender, EventArgs e) { DetailsView5.PageIndex = GridView5.SelectedIndex; }