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

AJAX call from Grid EditTemplate Control?

2 Answers 61 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 27 Oct 2009, 06:54 PM
I have a RadGrid with 3 columns in the master table only: 2 are read only and the other is an EditTemplate with a RadTextBox.  If in edit or insert mode and after the value of the textbox changes and loses focus, I want to do an AJAX call which will query the database for the newly entered value and then populate the 2 read only fields from the results.  So to the user, the 2 read only fields appear to get "auto populated" after the value of the textbox changes.  Is this possible?  All I really need help with is getting the textbox to call a sub in the codebehind.  I should be able to take it from there.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Oct 2009, 06:18 AM
Hi,

You can invoke an ajax request on the valuechanged client event of the RadTextBox as shown below:

aspx:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest1"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 
 
<telerik:RadGrid ID="RadGrid1" AutoGenerateEditColumn="true" DataSourceID="SqlDataSource1" runat="server">   
    <MasterTableView DataSourceID="SqlDataSource1"
        <Columns> 
            <telerik:GridTemplateColumn> 
                <EditItemTemplate> 
                    <telerik:RadTextBox ID="RadTextBox1" runat="server"
                        <ClientEvents OnValueChanged="ValueChanged" /> 
                    </telerik:RadTextBox> 
                </EditItemTemplate> 
            </telerik:GridTemplateColumn>  

js:
function ValueChanged() 
    { 
       var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>"); 
        ajaxManager.ajaxRequest(arguments); 
    } 

c#:
protected void RadAjaxManager1_AjaxRequest1(object sender, AjaxRequestEventArgs e) 
    { 
 
    } 

Also check out this help link to understand better.

Thanks
Princy.
0
Rob
Top achievements
Rank 1
answered on 28 Oct 2009, 02:47 PM
Yep, that works like a charm.  Thanks, Princy!
Tags
Ajax
Asked by
Rob
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rob
Top achievements
Rank 1
Share this question
or