Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
add Row to XamWebGrid from code behind
posted

private void XamWebGrid_CellExitingEditMode(object sender, ExitEditingCellEventArgs e)
        {           
            Infragistics.Silverlight.Controls.RowBase r = e.Cell.Row;           
            // Ensure using correct cell and editing has not been cancelled           
            if (e.Cell.Column.Key == "StepDescription" && !e.EditingCanceled)
            {
                ComboBox box = e.Editor as ComboBox;
                if (box.SelectedItem != null && ((ListItem)box.SelectedItem).Value!="0")
                {
                    Web.Cortex.WcfServiceReference.TestStepsProfile obj = new Web.Cortex.WcfServiceReference.TestStepsProfile(); ;
                    int StepId = Int32.Parse(((ListItem)box.SelectedItem).Value);
                    if (TestStepscollection != null && TestStepscollection.Count > 0)
                    {
                        var TestStepsMatch = TestStepscollection.Where(p => p.StepID == 6620);
                        //IEnumerable<Web.Cortex.WcfServiceReference.TestStepsProfile> qry = from c in TestStepscollection
                        //                                                                   where c.StepID == 6620
                        //                                                                   select c;                                               
                        //ObservableCollection<Web.Cortex.WcfServiceReference.TestStepsProfile> filteredClients = new ObservableCollection<Web.Cortex.WcfServiceReference.TestStepsProfile>(qry);

                        //IEnumerable<Web.Cortex.WcfServiceReference.TestStepsProfile> matches = TestS//tepscollection.Where(p => p.StepID == 6620);
                        foreach (Web.Cortex.WcfServiceReference.TestStepsProfile TestStep in TestStepsMatch)
                        {                           
                            rr.Cells["StepObjectClass"].Content = TestStep.StepObjectClass;
                            r.Cells["StepObjectClass"].Content = TestStep.StepObjectClass == null ? "" : TestStep.StepObjectClass;
                            r.Cells["StepObjectName"].Content = TestStep.StepObjectName == null ? "" : TestStep.StepObjectName;
                            //r.Cells["StepObjectAction"].Content = TestStep.StepObjectAction == null ? "" : TestStep.StepObjectAction;                           
                            r.Cells["StepID"].Content = TestStep.StepID == null ? "" : TestStep.StepID.ToString();
                            r.Cells["StepOrder"].Content = e.Cell.Row.Index + 1;                           
                            gridTransaction.Rows.Add((Row)r);                           
                            //TestStep.StepOrder = e.Cell.Row.Index + 1;
                            //TestStepList.Add(TestStep);                                   
                        }                       
                    }
                   
                    // New value is value of selected item in combo box
                    ////e.NewValue = ((ListItem)box.SelectedItem).Text;
                    box.ItemsSource = null;
                    box.SelectedItem = null;
                }
            }
        }

 

In above code I want to add the row in the grid.But as am doing

Infragistics.Silverlight.Controls.RowBase r = e.Cell.Row;  So the same row get copied again...

So anyone help me how to add new row in grid.I don't want to do it by modifying the collection object.

Parents Reply Children