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

[Solved] how to run Grid Client Event in code behind with RadAjaxManager

1 Answer 335 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lang dinh thien
Top achievements
Rank 1
lang dinh thien asked on 31 Aug 2009, 02:18 AM
hi all.
my problem is about the grid client event, i have a RadGrid, RadAjaxManager in this manager , i chose radgrid and i want to update the text box.
when i wrote a javascript for client event OnRowDoubleClick in pages aspx. i wrote a function
             function RowDblClick(sender,args){....}      
and i double click on Row , it's happened
    But when i wrote it in code behind (because i want to take a data in my database to update the testbox) i have the problem.if i don't have 2 parameters sender and args i sure the event  onrowdlouble click would not happen and i don't know how to chose the type for sender and args. could you give me a right function with right parameter to make the row double click on grid happen in code behind please.
thank you for listening.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Aug 2009, 04:49 AM
Hi Lang,

You can invoke an ajaxRequest from the OnRowDblClick event of Radgrid and pass the clicked row values as shown below. And in the code behind, you can extract passed parameter.

ASPX:
 
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AutoGenerateEditColumn="true" 
    DataSourceID="SqlDataSource1" GridLines="None"   > 
    <MasterTableView AutoGenerateColumns="False" ClientDataKeyNames="CustomerID" EditMode="EditForms" 
        DataSourceID="SqlDataSource1">        
        <Columns>                         
          . . . 
        </Columns> 
    </MasterTableView> 
    <ClientSettings> 
        <Selecting  AllowRowSelect="true" /> 
        <ClientEvents OnRowDblClick="OnRowDblClick" /> 
    </ClientSettings> 
</telerik:RadGrid> 

JavaScript:
 
<script type="text/javascript"
function OnRowDblClick(sender, args) 
    var myArray = new Array(); 
    myArray[0] = args.get_gridDataItem().getDataKeyValue('CustomerID'); 
    myArray[1] = args.get_gridDataItem()._itemIndexHierarchical; 
    $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(myArray);     
</script> 

C#:
 
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
    Label1.Text = (e.Argument.ToString()); 

Also checkout the following knowledge base:
Performing postback from grid client events

-Shinu.
Tags
Grid
Asked by
lang dinh thien
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or