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

Need to populate data in radwindow before displaying window

3 Answers 278 Views
Window
This is a migrated thread and some comments may be shown as answers.
Hunter
Top achievements
Rank 1
Hunter asked on 26 Nov 2012, 06:22 PM
I have a button image in a radGrid.  When the button image clicked I want to display a RadWindow.  But before I display the RadWindow I need to populate a datagrid contained in the RadWindow.

Radwindow
<telerik:RadWindow runat="server" ID="rwBulletins"
    RestrictionZoneID="ContentTemplateZone"  Modal="true" Width=700 Height=400
    Skin="Web20">
    <ContentTemplate>
 
    <asp:panel ID="pnlBulletin" runat="server" Width=700 BackColor="White" ForeColor="Black" BorderColor=Black BorderWidth=5 >
            <table>
                <tr>
                    <td>s
                        <b><asp:Label ID="Label10" runat="server"  Text="Bulletins" /></b>
                        <hr />
                    </td>
                </tr>
            <tr><td align="left">
                    <asp:panel ID="pnlBulletinBody" runat="server" ScrollBars=Vertical Height=400 Width=700  >
                        <table>
                            <tr>
                                <td>
                                    <asp:DataGrid ID="dgBulletins" runat="server" AutoGenerateColumns="false" >
                                        <AlternatingItemStyle BackColor="White" />
                                         
                                        <Columns>
                                            <asp:BoundColumn DataField="Description" HeaderText="Description" />
                                            <asp:TemplateColumn HeaderText="Author/Date">
                                                <ItemTemplate>
                                                    <%# Eval("Author") %><br />
                                                    <%# Eval("CreationDate") %>
                                                </ItemTemplate>
                                            </asp:TemplateColumn>
                                        </Columns>
                                    </asp:DataGrid>
                                    <br /><br />
                                    <asp:Label ID="lbBulletinParent" runat="server" />
                                </td>
                            </tr>
                        </table>       
                    </asp:panel>
                </td>
             </tr>
         </table>
    </asp:panel>
    </ContentTemplate>
</telerik:RadWindow>


I have tried using a static server button click handler where I populate the grid, but I can't get the RadWindow to display when I use the

VisibleOnPageLoad property.  (It does show if I cause another postback.  Am I missing an autopostback property setting somewhere?)

Image Button in RadGrid

<telerik:GridTemplateColumn HeaderText="Bulletins" ItemStyle-HorizontalAlign="Center" >
    <ItemTemplate>
        <asp:ImageButton ID="ibtnBulletin" CommandName="Bulletin" runat="server"
            ImageUrl='<%#BulletinImage(Eval("ClientID")) %>'  
            Onclick="ibtnBulletin_Click" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

Image Button Handler

Protected Sub ibtnBulletin_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
    Dim ibtn As ImageButton = CType(sender, ImageButton)
    Dim dgi As Telerik.Web.UI.GridDataItem = ibtn.Parent.Parent
 
    Dim ClientID As String = dgi.Cells(4).Text
    dgBulletins.DataSource = clsBulletins.GetBulletinsByClientandReseller(ClientID)
    dgBulletins.DataBind()
 
    rwBulletins.VisibleOnPageLoad = True
 
End Sub

I also tried calling a javascript function from the image button to display the RadWindow which works in displaying the RadWindow, but I couldn't figure out how to call the routine to populate the grid from the javascript.  So if that's a better approach I'm open to that.  Here's how that call looked so far:

<telerik:GridTemplateColumn HeaderText="Bulletins" ItemStyle-HorizontalAlign="Center" >
    <ItemTemplate>
        <asp:ImageButton ID="ibtnBulletin" CommandName="Bulletin" runat="server"
            ImageUrl='<%#BulletinImage(Eval("ClientID")) %>'
            OnClientClick="openWinContentTemplate(); return false;" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

And here's the javascript component:

<script type="text/javascript">
    function openWinContentTemplate() {
        $find("<%=rwBulletins.ClientID %>").show();
    }
 
</script>

Thanks for any help on this.

 

 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Nov 2012, 06:53 AM
Hi,

Please try the following code snippet to populate the DataGrid contained in the RadWindow and opening the RadWindow.

VB:
Protected Sub ibtnBulletin_Click(sender As Object, e As ImageClickEventArgs)
    dgBulletins.DataSourceID = "SqlDataSource1"
    dgBulletins.DataBind()
    Dim script As String = "function f(){$find(""" + rwBulletins.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
    ScriptManager.RegisterStartupScript(Page, Page.[GetType](), "key", script, True)
End Sub

Thanks,
Shinu.
0
Hunter
Top achievements
Rank 1
answered on 27 Nov 2012, 03:57 PM
Hi Shinu,

Thanks for such a quick response.  Since I Posted this I came up with almost exactly the same answer from continuing to go through your knowledge base.  However, in both of our solutions the contents of the Datagrid does not awlays get updated.  Actually it almost never gets updated.  I step through the code and I can verify that the datatable returned from my populating function gives me the correct data everytime for the selection made, but it sometimes does not display any results in the window, or when it does display results the results they do not get updated on subsequent selections from another row in my radGrid.

Any ideas?

Thanks,
Hunter

0
Rumen
Telerik team
answered on 30 Nov 2012, 08:51 AM
Hi,

The problem could be due to the AJAX configuration. You can find detailed information on how to use RadWindow with AJAX in this article: How to Use RadWindow with AJAX.

For example, you can wrap RadGrid in Asp:UpdatePanel with UpdateMode="Conditional". When the postback is from the Grid it will be updated. If the postback is triggered by external controls you should fire the Update() method of the UpdatePanel.

If you are unable to fix the problem, isolate it in a simple fully working project and send it for examination via a support ticket.

All the best,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Hunter
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Hunter
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or