Ticket Q261714
Visible to All Users

ASPxGridView inside ASPxPopupControl

created 15 years ago

I'm trying to put an ASPxGridView inside of a PopupControl. Here is my markup:
<dx:ASPxGridView ID="ASPxGridView1" runat="server" Width="100%" AutoGenerateColumns="False"
        KeyFieldName="ID">
        <columns>
                    <dx:GridViewDataCheckColumn Caption="Select" FieldName="IsSelected" VisibleIndex="0">
                        <DataItemTemplate>
                            <input id="Radio1" type="radio" value='<%# GetFieldValue(Container.DataItem) %>'
                                <%#GetFieldChecked(Container.DataItem)%> name="myradio" />

</DataItemTemplate>
                    </dx:GridViewDataCheckColumn>
                    <dx:GridViewDataHyperLinkColumn VisibleIndex="0" Caption="ID" FieldName="ID">
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="~/ParticipantSummary.aspx?id={0}">
                        </PropertiesHyperLinkEdit>
                    </dx:GridViewDataHyperLinkColumn>
                    <dx:GridViewDataTextColumn VisibleIndex="1" Caption="Full Name" FieldName="FullName">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn VisibleIndex="2" Caption="Test" FieldName="Test">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn VisibleIndex="3" Caption="DOB" FieldName="DOB" PropertiesTextEdit-DisplayFormatString="d">
                        <PropertiesTextEdit DisplayFormatString="d">
                        </PropertiesTextEdit>
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn VisibleIndex="4" Caption="Address" FieldName="FullAddress">
                    </dx:GridViewDataTextColumn>
                </columns>
        <settings gridlines="None" showcolumnheaders="False" />
        <settingsbehavior allowfocusedrow="True" />
        <clientsideevents focusedrowchanged="function(s, e) {
               var row = s.GetRow(s.GetFocusedRowIndex());
                if(__aspxIE)
                {
                    row.cells[0].childNodes[0].checked = true;
                }
                else
                    row.cells[0].childNodes[1].checked = true;
}" />
    </dx:ASPxGridView>
And here is my databinding:
List<Participant> parts = service.GetResults();
                List<ParticipantExistsView> views = new List<ParticipantExistsView>();
                foreach (Participant p in parts)
                {
                    views.Add(new ParticipantExistsView(p.ID, p.Contact.FirstName, p.Contact.LastName,
                        p.Test, p.DOB, p.Contact.Address.Address1, p.Contact.Address.Address2,
                        p.Contact.Address.City, p.Contact.Address.State, p.Contact.Address.PostalCode));
                }

ASPxGridView1.DataSource = views;
                ASPxGridView1.DataBind();
                //ASPxPopupControl1.ShowOnPageLoad = true;
                ASPxPopupControl1.Modal = true;
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "ShowPopup", "PopupControl.Show();", true);
There are a few problems with this:

  1. The GridView ClientScript for radio button selection per your tutorial ( http://www.devexpress.com/Support/Center/e/E135.aspx ) throws a script error.
  2. ASPxPopupControl1.ShowOnPageLoad doesn't work, I have to register the startup script just to show the popup.
  3. The biggest problem, my GridView won't display data despite being databound. I've also tried other methods of loading data to other user controls I have and the user controls render fine, but with no data. What do I need to do to get my GridView to show properly? (Or any other control that needs data from the server).
    Note: I need to programatically show this PopupControl - as well as programatically databind controls in it's content panel.
Comments (3)
DevExpress Support Team 15 years ago

    Hello Jeffrey,
    Thanks for questions.
    >>1) The GridView ClientScript for radio button selection per your tutorial ( http://www.devexpress.com/Support/Center/e/E135.aspx ) throws a script error.
    I'm afraid, I couldn't reproduce your issue (see the attached video). It looks like some other things are involved in this issue, which I have not taken into consideration.
    >>2) ASPxPopupControl1.ShowOnPageLoad doesn't work, I have to register the startup script just to show the popup.
    I assume that there is some misunderstanding concerning the ASPxPopupControl.ShowOnPageLoad property. The ShowOnPageLoad doesn't provide the display of the ASPxPopupControl on the server. It only means that the popup control will be shown during the first page load in a property set in the markup, or just after adding it to a page, if it is created on the server side. Therefore, the display of the ASPxPopupControl by using a script is correct approach in your scenario.
    >>3) The biggest problem, my GridView won't display data despite being databound.
    Unfortunately, you didn't write when you bind the grid. Do you bind it via a callback? I'd like to note that by design, while in callback processing, our ASP.NET controls can update only their own render, but not the render of outside controls. In particular, it's impossible to reload the GridView's data.
    Based on these points, we need a simple running project (not just a code snippet or a separate file) so that we can reproduce and pinpoint the problem, understand the logic of your application and provide a solution.
    Thanks,
    Marion

      1. This was fixed easily - the javascript in your example assumes the Grid has already been databound. I changed the javascript to add a simple if(row != null) check to get around this. Note: I think the original javascript error would only show up in debugging, I doubt it would in an actual deployment. Here is my change:
        <ClientSideEvents FocusedRowChanged="function(s, e) {
             var row = s.GetRow(s.GetFocusedRowIndex());
            if(row != null)
            {
                 if(__aspxIE)
                {
                     row.cells[0].childNodes[0].checked = true;
                    btnSelected.SetEnabled(true);
                }
                else
                     row.cells[0].childNodes[1].checked = true;
            }
        }" />
      2. That's fine, it works perfectly well this way
      3. This was entirely my error. I was binding my GridView in the TextChanged event of an ASPxTextBox. The problem was this TextBox was in a user control that was held in a UpdatePanel that the GridView wasn't also in. So the DataBinding was performed but the GridView wasn't being rendered again.
        Thanks for the help guys!
      DevExpress Support Team 15 years ago

        Hello Jeffrey,
        You always welcome!
        Thanks,
        Marion

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.