I am able to get the datakeyvalue for the 1st level of the radgrid, but now trying to get the datakey value fo rthe second level of the radgrid to do an insert at the 3rd level of the radgrid. I used the same statement for the 3rd level but it always returns 0, so I know its not working. I tried putting in parent.parent but nothing seems to work for me.
It is this peice in the 3rd level insert
It is this peice in the 3rd level insert
GridDataItem parentItem = e.Item.OwnerTableView.ParentItem;
int PosId = Convert.ToInt32(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["intpositionId"]);
// all the Insert Commands for the Grids in order of Grid Heirarchy
//Insert command for the Sections 1st level
if (e.CommandName == RadGrid.PerformInsertCommandName && e.Item.OwnerTableView.Name == "Sections")
{
GridEditableItem item = e.Item as GridEditableItem;
TextBox section = (TextBox)item.FindControl("txtSection");
sql = "Execute usp_InsertSection '" + c.SanitizeString(section.Text) + "', " + c.GetUserId();
c.InsertUpdateDelete(sql);
myradGrid.Rebind();
}
//Insert command for positions 2nd Level
if (e.CommandName == RadGrid.PerformInsertCommandName && e.Item.OwnerTableView.Name == "Positions")
{
GridEditableItem item = e.Item as GridEditableItem;
GridDataItem parentItem = e.Item.OwnerTableView.ParentItem;
//int sectionId = Convert.ToInt32(item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["intSectionId"]);
int secId = Convert.ToInt32(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["intSectionId"]);
TextBox descrip = (TextBox)item.FindControl("txtdescription");
TextBox scale = (TextBox)item.FindControl("txtScale");
TextBox posType = (TextBox)item.FindControl("txtPosType");
TextBox grade = (TextBox)item.FindControl("txtGrade");
sql = "Execute usp_InsertPosition " + secId + ", '" + c.SanitizeString(descrip.Text) + "', '" + c.SanitizeString(scale.Text) + "', '" + c.SanitizeString(posType.Text) + "', '" + c.SanitizeString(grade.Text) + "'";
c.InsertUpdateDelete(sql);
}
//Insert for Personnel added to the Position 3rd Level
if (e.CommandName == RadGrid.PerformInsertCommandName && e.Item.OwnerTableView.Name == "Personnel")
{
GridEditableItem item = e.Item as GridEditableItem;
GridDataItem parentItem = e.Item.OwnerTableView.ParentItem;
int PosId = Convert.ToInt32(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["intpositionId"]);
CheckBox backfill = (CheckBox)item.FindControl("cbBackFill");
CheckBox manager = (CheckBox)item.FindControl("cbManager");
CheckBox assistManager = (CheckBox)item.FindControl("cbAssistMan");
int backfillck = 0;
int managerck = 0;
int assManagerck = 0;
if (backfill.Checked == true)
{
backfillck = 1;
}
if (manager.Checked == true)
{
managerck = 1;
}
if (assistManager.Checked == true)
{
assManagerck = 1;
}
sql = "Execute usp_InsertPersonnel " + PosId + ", " + HFAdminId.Value + ", " + backfillck + ", " + managerck + ", " + assManagerck + "";
Response.Write(sql);
Response.End();
c.InsertUpdateDelete(sql);
}