Call SQL Data Source Insert based on a session variable from RadWindow

3 posts, 0 answers
  1. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 27 Oct 2009 Link to this post

    Hello,

    I have a scenario where I have a RadWindow that is opened from a LinkButton click (after some fields are validated). The RadWindow is created, added to RadWindowManager and opened through server side code. On the Radwindow there are two LinkButtons. I create a session variable and assign that session variable a value based on which link button is clicked. Also, each linkbutton closes the RadWindow when clicked. Now, based on the value in the session variable, I would like to call the Insert of a SqlDataSource and then rebind a RadGrid OR do nothing. I have no problem with setting this up to do nothing. The issue I have is trying to call the Insert of the SqlDataSource and then rebinding the RadGrid.

    Any clues as to how to do this? I've tried to do so using an Ajax request, but either I did it wrong or it won't work from the click of a LinkButton.

    Thanks,
    Casey
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 30 Oct 2009 Link to this post

    Hi Casey,

    How exactly did you try to invoke the ajaxRequest() method? Note that apart from calling the method, you should also make sure that you have set the OnAjaxRequest property to the RadAjaxManager. A sample of this approach is available in the Window Editing demo where we update RadGrid by using ajaxRequest().

    If you still experience problems with this task, please open a support ticket and send us a small sample project where the problem can be reproduced. Just make sure that the project can be run locally and attach it to the support thread.


    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 30 Oct 2009 Link to this post

    Hi Georgi,

    I was able to get this figured out finally. I was able to achieve what I wanted by calling a javascript function on the parent page when the "Agree" button on the RadWindow was clicked. The "Agree" button also closed the RadWindow. The javascript function I call initiates an ajax request and the method in my code behind runs the insert and then rebinds the RadGrid. Code is below.

    Parent Page javascript function:
    function refreshGrid() {  
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");  
            } 

    Parent Page OnAjaxRequest method:
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)  
        {  
            if (e.Argument.ToString() == "Rebind")  
            {  
                foreach (GridDataItem i in RadGrid2.Items)  
                {  
                    if (i.Selected)  
                    {  
                        HiddenText1.Value = i["ID"].Text;  
                        SqlDataSource3.Insert();  
                        i.Selected = false;  
                    }  
                }  
                RadGrid1.Rebind();  
            }  
        } 

    "Agree" linkbutton definition:
    <asp:LinkButton ID="Agree" runat="server" onclick="Yes_Click" 
                              OnClientClick="OnClientClick_Edit()">Agree</asp:LinkButton>

    RadWindow javascript function:
    function OnClientClick_Edit() {  
              var oWindow = GetRadWindow().BrowserWindow;  
              oWindow.refreshGrid();  
          } 

Back to Top