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

[Solved] Controls and Grid not refreshing in WindowManager Content Page popup

1 Answer 116 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Aniket Braganza
Top achievements
Rank 2
Aniket Braganza asked on 20 May 2009, 04:31 AM
I have a button in my grid that uses a WindowManager to open a RadWindow. In the popup RadWindow I add a new record to a list using some drop downs and textboxes. After I click Add I want the controls to be cleared and the grid below to be refreshed with the new record. I added a RadAjaxManagerProxy to this page and tried to point to those controls to be updated but nothing happens. When I press the refresh on the grid itself then the record shows up but otherwise everything on the popup page remains unchanged. 

How do I get the controls on this page to refresh properly?

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="btnAdd"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="ddlTeacher" /> 
                    <telerik:AjaxUpdatedControl ControlID="ddlSubject" /> 
                    <telerik:AjaxUpdatedControl ControlID="txtStartTime" /> 
                    <telerik:AjaxUpdatedControl ControlID="txtLessonLength" /> 
                    <telerik:AjaxUpdatedControl ControlID="txtComments" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    <telerik:AjaxUpdatedControl ControlID="GridView1" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnAdd" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManagerProxy> 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" 
        Width="75px"
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' 
            style="border: 0px;" /> 
    </telerik:RadAjaxLoadingPanel> 
    <table> 
        <tr> 
            <td> 
                <asp:Label ID="lblTeacher" runat="server" Text="Teacher:" AssociatedControlID="ddlTeacher"></asp:Label> 
                <telerik:RadComboBox ID="ddlTeacher" runat="server" EnableLoadOnDemand="true" Width="300px" 
                    Height="200px" EnableVirtualScrolling="true" OnItemsRequested="ddlTeacher_ItemsRequested"
                </telerik:RadComboBox> 
            </td> 
            <td> 
                <asp:RequiredFieldValidator ID="TeacherRequired" runat="server" ControlToValidate="ddlTeacher" 
                    ErrorMessage="Teacher is required." ToolTip="Teacher is required." ValidationGroup="AddLessonGroup">*</asp:RequiredFieldValidator> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                <asp:Label ID="lblSubject" runat="server" Text="Subject:" AssociatedControlID="ddlSubject"></asp:Label> 
                <telerik:RadComboBox ID="ddlSubject" runat="server" EnableLoadOnDemand="true" Width="300px" 
                    Height="200px" EnableVirtualScrolling="true" OnItemsRequested="ddlSubject_ItemsRequested"
                </telerik:RadComboBox> 
            </td> 
            <td> 
                <asp:RequiredFieldValidator ID="SubjectRequired" runat="server" ControlToValidate="ddlSubject" 
                    ErrorMessage="Subject is required." ToolTip="Subject is required." ValidationGroup="AddLessonGroup">*</asp:RequiredFieldValidator> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                <asp:Label ID="lblStartTime" runat="server" Text="Start Time:" AssociatedControlID="txtStartTime"></asp:Label> 
                <telerik:RadDateTimePicker ID="txtStartTime" runat="server" Skin="Default"
                </telerik:RadDateTimePicker> 
            </td> 
            <td> 
                <asp:RequiredFieldValidator ID="StartTimeRequired" runat="server" ControlToValidate="txtStartTime" 
                    ErrorMessage="Start Time is required." ToolTip="Start Time is required." ValidationGroup="AddLessonGroup">*</asp:RequiredFieldValidator> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                <asp:Label ID="lblLessonLength" runat="server" Text="Lesson Length:" AssociatedControlID="txtLessonLength"></asp:Label> 
                <telerik:RadNumericTextBox ID="txtLessonLength" runat="server"
                </telerik:RadNumericTextBox> 
            </td> 
            <td> 
                <asp:RequiredFieldValidator ID="LessonLengthRequired" runat="server" ControlToValidate="txtLessonLength" 
                    ErrorMessage="Lesson Length is required." ToolTip="Lesson Length is required." 
                    ValidationGroup="AddLessonGroup">*</asp:RequiredFieldValidator> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                <asp:Label ID="lblComments" runat="server" Text="Comments:" AssociatedControlID="txtComments"></asp:Label> 
                <telerik:RadEditor ID="txtComments" runat="server" EditModes="Design" Height="200px" Width="100%"
                    <Tools> 
                        <telerik:EditorToolGroup> 
                            <telerik:EditorTool Name="AjaxSpellCheck" /> 
                            <telerik:EditorTool Name="Undo" /> 
                            <telerik:EditorTool Name="Redo" /> 
                            <telerik:EditorTool Name="SelectAll" /> 
                            <telerik:EditorTool Name="Cut" /> 
                            <telerik:EditorTool Name="Copy" /> 
                            <telerik:EditorTool Name="Paste" /> 
                            <telerik:EditorTool Name="FontName" /> 
                            <telerik:EditorTool Name="FontSize" /> 
                            <telerik:EditorTool Name="Bold" /> 
                            <telerik:EditorTool Name="Italic" /> 
                            <telerik:EditorTool Name="Underline" /> 
                            <telerik:EditorTool Name="Subscript" /> 
                            <telerik:EditorTool Name="Superscript" /> 
                            <telerik:EditorTool Name="JustifyCenter" /> 
                            <telerik:EditorTool Name="JustifyFull" /> 
                            <telerik:EditorTool Name="JustifyLeft" /> 
                            <telerik:EditorTool Name="JustifyNone" /> 
                            <telerik:EditorTool Name="JustifyRight" /> 
                        </telerik:EditorToolGroup> 
                    </Tools> 
                    <Content> 
                     
</Content> 
                </telerik:RadEditor> 
            </td> 
            <td> 
            </td> 
        </tr> 
        <tr> 
            <td colspan="2" style="text-align: right;"
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="AddLessonGroup" /> 
            </td> 
        </tr> 
        <tr> 
            <td colspan="2" style="text-align: right;"
                <asp:Button ID="btnAdd" runat="server" Text="Add Lesson" OnClick="btnAdd_Click" /> 
            </td> 
        </tr> 
    </table> 
    <div class="subHeader"
        Current Lessons 
    </div> 
    <telerik:RadGrid ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" 
        AllowMultiRowSelection="true" OnDeleteCommand="GridView1_DeleteCommand" OnNeedDataSource="GridView1_NeedDataSource" 
        OnUpdateCommand="GridView1_UpdateCommand" OnItemCreated="GridView1_ItemCreated" 
        OnPreRender="GridView1_PreRender"
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="Lessonid" CommandItemDisplay="Top"
            <SortExpressions> 
                <telerik:GridSortExpression FieldName="Starttime" /> 
            </SortExpressions> 
            <Columns> 
                <telerik:GridBoundColumn DataField="Lessonid" DataType="System.Guid" HeaderText="Lessonid" 
                    ReadOnly="True" SortExpression="Lessonid" UniqueName="Lessonid" Visible="False"
                </telerik:GridBoundColumn> 
                <telerik:GridEditCommandColumn> 
                </telerik:GridEditCommandColumn> 
                <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete" 
                    ConfirmText="Are you sure you want to delete the selected row?"
                </telerik:GridButtonColumn> 
                <telerik:GridBoundColumn DataField="Studentname" HeaderText="Student Name" ReadOnly="True" 
                    SortExpression="Studentname" UniqueName="Studentname"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Studentid" HeaderText="Studentid" ReadOnly="True" 
                    Visible="false" SortExpression="Studentid" UniqueName="Studentid"
                </telerik:GridBoundColumn> 
                <telerik:GridDropDownColumn DataField="Teacherid" DataType="System.Guid" HeaderText="Teacher" 
                    SortExpression="Teacherid" UniqueName="Teacherid" DataSourceID="TeacherDataSource1" 
                    ListTextField="Teachername" ListValueField="Teacherid"
                </telerik:GridDropDownColumn> 
                <telerik:GridDropDownColumn DataField="Subjectid" DataType="System.Guid" HeaderText="Subject" 
                    SortExpression="Subjectid" UniqueName="Subjectid" DataSourceID="SubjectDataSource1" 
                    ListTextField="Subjectname" ListValueField="Subjectid"
                </telerik:GridDropDownColumn> 
                <telerik:GridDateTimeColumn DataField="Starttime" DataType="System.DateTime" HeaderText="Start Time" 
                    SortExpression="Starttime" UniqueName="Starttime" PickerType="DateTimePicker"
                </telerik:GridDateTimeColumn> 
                <telerik:GridNumericColumn DataField="Lessonlength" HeaderText="Lesson Length (mins)" 
                    SortExpression="Lessonlength" UniqueName="Lessonlength"
                </telerik:GridNumericColumn> 
                <telerik:GridBoundColumn DataField="Status" HeaderText="Lesson Status" ReadOnly="True" 
                    SortExpression="Status" UniqueName="Status"
                </telerik:GridBoundColumn> 
                <telerik:GridHTMLEditorColumn DataField="Comments" HeaderText="Comments" SortExpression="Comments" 
                    UniqueName="Comments" Visible="False" ColumnEditorID="commentEditor"
                </telerik:GridHTMLEditorColumn> 
            </Columns> 
            <EditFormSettings CaptionFormatString="Edit Lesson Details."
                <FormStyle BorderColor="Gray" BorderWidth="2px" BorderStyle="Outset" /> 
                <PopUpSettings ScrollBars="Auto" Modal="True" Width="800px" Height="550px" /> 
                <EditColumn UniqueName="EditCommandColumn1"
                </EditColumn> 
            </EditFormSettings> 
            <PagerStyle Mode="NextPrevNumericAndAdvanced" /> 
            <CommandItemTemplate> 
                <table width="100%"
                    <td style="text-align: right;"
                        <asp:LinkButton ID="Refresh" runat="server" CommandName="RebindGrid"
                            <asp:Image ID="Image2" Style="border: 0px; vertical-align: middle;" ImageUrl="~/Images/Refresh.gif" 
                                runat="server" /> 
                            Refresh List</asp:LinkButton> 
                    </td> 
                    </tr> 
                </table> 
            </CommandItemTemplate> 
        </MasterTableView> 
    </telerik:RadGrid> 
    <asp:SqlDataSource ID="SubjectDataSource1" runat="server"></asp:SqlDataSource> 
    <asp:SqlDataSource ID="TeacherDataSource1" runat="server"></asp:SqlDataSource> 
</asp:Content> 
 
 

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 25 May 2009, 07:14 AM

Hello Aniket,

In order to update the grid after you have added a new record, you should rebind it. You can do this by handling the OnAjaxRequest of the RadAjaxManager. You can examine this approach in the following online demo:

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window

When you install RadControls, our online examples projects are automatically installed on your computer and you can not only examine their full source code, but also extend them further in order to meet your requirements.

You can open the demos from here:

Start\Programs\Telerik\RadControls for ASPNET AJAX\Open Sample WebSite In VisualStudio

The actual location on your hard disk is the following one:

C:\Program Files\Telerik\RadControls for ASPNET AJAX \Live Demos

Please, examine the full source code of the demo and use it as a start pint for your implementation. In case you need further assistance, prepare a sample, fully runnable reproduction demo (e.g use Northwind for the grid), open a new support ticket and send it to me along with detailed reproduction steps of the actual and the desired behavior and I will do my best to help.


Kind regards,

Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Aniket Braganza
Top achievements
Rank 2
Answers by
Svetlina Anati
Telerik team
Share this question
or