Home Forums WinForms controls Xceed Grid for WinForms Problem adding rows to Detail Grid

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13700 |

    I have used the code that was shown as examples in previous postings about this topic but without luck. Here are the specifics:

    I have a master/detail grid that looks like this:
    +Project Name Created
    ——Task Name

    Function to load this is below but problem is that the code executes fine but I do not see the value of “test” under the Task Name column of the detail grid. What am I doing wrong?

    private void LoadProjectsDataset()
    {
    string strSQL = “GetProject null”;
    DataAccess dal = new DataAccess();
    DataSet ds = dal.ExecuteSPDataset(connString, strSQL, “projects”);

    grdProjects.BeginInit();
    foreach (System.Data.DataRow row in ds.Tables[0].Rows)
    {
    //grdProjects is a master grid
    Xceed.Grid.DataRow rowAdd = grdProjects.DataRows.AddNew();
    rowAdd.Cells[“colProjName”].Value = row.ItemArray.GetValue(1).ToString();
    rowAdd.Cells[“colProjCreate”].Value = row.ItemArray.GetValue(2);
    rowAdd.EndEdit();
    //dtlProjectTasks is a detailGridTemplate under grdProjects Master grid
    Xceed.Grid.DataRow row2 = dtlProjectTasks.DataRows.AddNew();
    row2.Cells[“colProjTaskName”].Value = “test”;
    row2.EndEdit();
    }
    grdProjects.EndInit();
    }

    Imported from legacy forums. Posted by jbailey (had 2526 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi jbailey,
    I am still having troubles adding rows to the detail grid as well. I am working with Xceed Support on the issue and will post the results once I have working code.

    Try adding the row by calling the master grid and let me know what happens, Something like:
    Xceed.Grid.DataRow newRow = gridControl1.DataRows[0].DetailGrids[0].DataRows.AddNew();

    I have tried this and got it to work once. But only once. I removed the code, and added it back, in the same place it was before, and it refuses to add the row. Not sure if there is something else in my code causing this. If it works for you, I can at least start looking through the code to see if there is anything else causing my difficulties.
    Good luck!

    Ken

    Imported from legacy forums. Posted by KenG (had 391 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks to the good folks at Xceed support, I have some working code regarding this issue.

    Here is what I end up with.
    If you have selected a row in the master grid,
    foreach (Xceed.Grid.DataRow dataRow in masterGrid.SelectedRows)
    {
    Xceed.Grid.DataRow newRow = dataRow.DetailGrids[0].DataRows.AddNew();
    // be sure to assign any required data
    newRow.Cells[“name of the cell”].Value = value;
    newRow.EndEdit();
    }

    If the selected row is in the detail grid,
    foreach (Xceed.Grid.DataRow dataRow in masterGrid.SelectedRows)
    {
    Xceed.Grid.DataRow newRow = dataRow.ParentGrid.DataRows.AddNew();
    // be sure to assign any required data
    newRow.Cells[“name of the cell”].Value = value;
    newRow.EndEdit();
    }

    It is imperitave that any required data be entered into the appropiate cell values or the row will not be created. There may be no errors to tell you what is going on.

    I hope this helps out. Please let me know if you find other code examples that works better, of if this code does not get you going.

    Thanks

    KenG

    Imported from legacy forums. Posted by KenG (had 3610 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.