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

SelectedIndexChanged on RowDblClick

7 Answers 206 Views
Grid
This is a migrated thread and some comments may be shown as answers.
asimptota
Top achievements
Rank 1
asimptota asked on 31 Jan 2013, 08:31 AM
I am building a user .ascx control that contains a RadGrid. On row double click I have to be able to get Id value of that grid and a value in "Title" column and place them in TextBoxes on a parent form. Now, I have made a custom event for this (called it SelectEvent) which will be handled on parent form, and have defined custom event args class (PickereventArgs with two properties: int ID, string Title). I want to raise that event on SelectedIndexChanged of the RadGrid in .ascx like this
protected void gridPicker_SelectedIndexChanged(object sender, EventArgs e)
{
 
    foreach (GridDataItem item in gridPicker.SelectedItems)
    {
        if (item.Selected)
        {
            if (SelectEvent != null)
            {
                PickerEventArgs args = new PickerEventArgs();
                args.Title = item.Cells[1].Text;
                args.Id = Convert.ToInt32(item.Cells[0].Text);
                SelectEvent(this,args);
                gridPicker.DataSource = null;
                this.Visible = false;
            }
        }
    }    
}

but I can't fire OnSelectedIndexChange with double click on row.
Help, anyone? I need it quickly because I have a deadline and my boss is getting a bit nervous :)

7 Answers, 1 is accepted

Sort by
0
asimptota
Top achievements
Rank 1
answered on 01 Feb 2013, 07:37 AM
Anyone? Please, I'm stuck on this for three days :)
0
Princy
Top achievements
Rank 2
answered on 01 Feb 2013, 09:34 AM
Hi,

In your RowDblClick js function, you could perform an ajax call by calling the RadAjaxManager and including a CommandArgument to the AjaxRequest() method. Please take a look into the following code snippet.

Javascript:
function RowDblClick(sender, eventArgs)
{
    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("SelectedIndexChanged");
}

C#:
protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
    if (e.Argument == "SelectedIndexChanged")
    {
        //Your code
    }
}

Thanks,
Princy.
0
asimptota
Top achievements
Rank 1
answered on 01 Feb 2013, 09:45 AM
I understand but, I am using RadAjaxmanagerProxy in my .ascx user control because I already have RadAjaxManager in the form where I have to put my control. How can I hadle AjaxRequest in this case?
0
Jayesh Goyani
Top achievements
Rank 2
answered on 01 Feb 2013, 10:00 AM
0
Princy
Top achievements
Rank 2
answered on 01 Feb 2013, 10:03 AM
Hi,

Please try the following Javascript in the UserControl.

Javascript:
function RowDblClick(sender, eventArgs)
 {      
    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("SelectedIndexChanged");
 }

Thanks,
Princy.
0
asimptota
Top achievements
Rank 1
answered on 01 Feb 2013, 10:32 AM
Thank you guys for your answers, but it doesn't work.

Jayesh: I've tried but it doesn't fire RadGrid1_ItemCommand event at all. Am I missing something?
Princy: this calls RowDblClick function on the form where I've placed my control but I can't access RadGrid that is within that control.

This is really frustrating...
0
Princy
Top achievements
Rank 2
answered on 01 Feb 2013, 11:10 AM
Hi,

Please try the following code snippet to access the Radgrid in the UserControl.

C#:
protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
       RadGrid grid = (RadGrid)UserControlID.FindControl("RadGridID");
}

Thanks,
Princy.
Tags
Grid
Asked by
asimptota
Top achievements
Rank 1
Answers by
asimptota
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Jayesh Goyani
Top achievements
Rank 2
Share this question
or