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

Home / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Ajax > RadAjaxManager and RegisterStartupScript

3 Answers 66 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
JohnS
Top achievements
Rank 1
JohnS asked on 29 Jan 2013, 10:39 PM


I am trying to update a grid that is bound.  When I hit the javascript code that does the close and rebind the args are undefined (see code snippet 1.  As I step through the server side code all looks good. I tried using both ScriptManager and ClientScript.  Any thoughts???  thanks...
code snippet 1....
            function CloseAndRebind(args) {
                alert('args ' + args);
                GetRadWindow().BrowserWindow.refreshGrid(args);
                GetRadWindow().close();
            }

code snippet 2...
        protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            if (e.CommandName == "Update")
            {
                //ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
                ScriptManager.RegisterStartupScript(this,Page.GetType(), "mykey", "CloseAndRebind();", true);
            }
}

protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            //logic to truncate long string to prevent SQL error
            for (int i = 1; i < 6; i++)
            {
                string val = e.NewValues[i - 1].ToString();
                int maxLength = i * 10;
                if (val.Length > maxLength) e.NewValues[i - 1] = val.Substring(0, maxLength);
            }
        }

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 01 Feb 2013, 02:35 PM
Hello John,

I would suggest you to review the online example bellow which presents the same functionality and works as expected. Test it on your end and verify what the difference in your case is:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window

Regards,
Maria Ilieva
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.
0
JohnS
Top achievements
Rank 1
answered on 04 Feb 2013, 10:09 PM
It seems that the the SQLDataSource does not get refreshed with the query string's selected key.  In the example below the   SQLDataSource 
DefaultValue="2".  The value "2" sticks even though I see that the  server side is passed the Request.QueryString["Obj_CommentID" = 1.  I replaced most of my code from your sample and I still have the issue.  Any more thoughts?......



CLIENT SIDE
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PEGASUS_ConnectionString %>"
                                    ProviderName="<%$ ConnectionStrings:PEGASUS_ConnectionString.ProviderName %>"
   InsertCommand="INSERT INTO [ObjectiveComments] ([ObjectiveID], [Comment]) VALUES (@ObjectiveID, @Comment)"
   SelectCommand="SELECT Obj_CommentID, ObjectiveID, Comment FROM ObjectiveComments WHERE (Obj_CommentID = ?)"
                                    
                    UpdateCommand="UPDATE [ObjectiveComments] SET [Comment] = @Comment WHERE [Obj_CommentID] = @Obj_CommentID">
<InsertParameters>
<asp:Parameter Name="ObjectiveID" Type="Int32" />
<asp:Parameter Name="Comment" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Comment" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" />
<asp:Parameter Name="Obj_CommentID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter Name="Obj_CommentID" 
                            QueryStringField="@Obj_CommentID" Type="Int32" DefaultValue="2" />
</SelectParameters>
</asp:SqlDataSource>


SERVER SIDE
            if (Request.QueryString["Obj_CommentID"] == null)
            {
                DetailsView1.DefaultMode =
                    DetailsViewMode.Insert;
            }
            else
            {
                DetailsView1.DefaultMode =
                    DetailsViewMode.Edit;
                //SqlDataSource1.SelectParameters["Obj_CommentID"].DefaultValue = Request.QueryString["Obj_CommentID"].ToString();
            }
0
Maria Ilieva
Telerik team
answered on 07 Feb 2013, 02:29 PM
Hi John,

In this case it will be best if you could open a regular support ticket and send us sample runnable application as well as the DB so that we could test the application locally.Thus we will able to further research on the issue and provide a proper solution for your case.

Regards,
Maria Ilieva
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
Ajax
Asked by
JohnS
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
JohnS
Top achievements
Rank 1
Share this question
or