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

How can I persist the row selection of radgrid after updating child gridview

3 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dorababu
Top achievements
Rank 1
Dorababu asked on 05 Jul 2012, 01:33 PM
I am having two radgrids where I will show master data in one grid and when selecting the corresponding row I will show the data in child radgrid. As per the attached Image I would like to achieve my scenario can some one help me

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 09 Jul 2012, 06:07 AM
Hello Dorababu,

I have created a sample RadGrid web site where I implemented the requested functionality. Please check out the attached application and let me know in case you need further assistance.

Regards,
Eyup
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
Dorababu
Top achievements
Rank 1
answered on 09 Jul 2012, 07:52 AM
Hi I would like to achieve this using server side functionality
0
Eyup
Telerik team
answered on 11 Jul 2012, 02:24 PM
Hello Dorababu,

I am not familiar with your specific scenario and the way your grids are related, however, you could get the row being edited on ItemCommand server event and highlight the corresponding parent item in the main grid:
protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.EditCommandName)
        {
            string relationFieldKey = (e.Item as GridDataItem)["CustomerID"].Text;
            foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)
            {
                if (dataItem["CustomerID"].Text == relationFieldKey)
                {
                    dataItem.BackColor = System.Drawing.Color.Lime;
                    // or dataItem.Selected=true;
                    Session["itemIndex"] = dataItem.ItemIndex;
                    break;
                }
            }
        }
        else if (e.CommandName == RadGrid.CancelCommandName || e.CommandName == RadGrid.UpdateCommandName
            || e.CommandName == RadGrid.PerformInsertCommandName)
        {
            RadGrid1.MasterTableView.Items[(int)Session["itemIndex"]].BackColor = new System.Drawing.Color();
            // or  RadGrid1.MasterTableView.Items[(int)Session["itemIndex"]].Selected=false;
        }
    }

I hope this will prove helpful.

All the best,
Eyup
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
Grid
Asked by
Dorababu
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Dorababu
Top achievements
Rank 1
Share this question
or