Hi,
I have a dynamically created RadGrid. Now on expanding the child tables in the Grid, I want to get the name of the tableView on "grv_ItemCommand" event. Here is my code:
Please assist me....
thanks
Rohan
I have a dynamically created RadGrid. Now on expanding the child tables in the Grid, I want to get the name of the tableView on "grv_ItemCommand" event. Here is my code:
private void BindData() { clickedType = Session["type"].ToString(); int id = ParentEntity.ParentEntityId; GridTableView tableView = new GridTableView(grv); switch (clickedType) { case "All Categories": using (SpaceCategoriesService.SpaceCategoriesServiceClient s = new SpaceCategoriesService.SpaceCategoriesServiceClient()) { grv.DataSource = s.GetCategoryTable(); tableView.Name = "Buildings"; tableView.DataMember = "Buildings"; } break; case "SpaceCategories": using (SpaceBuildingsService.SpaceBuildingsServiceClient s = new SpaceBuildingsService.SpaceBuildingsServiceClient()) { grv.DataSource = s.GetBuildingByCategoryId(id); tableView.Name = "Floors"; tableView.DataMember = "Floors"; } break; case "SpaceBuildings": using (SpaceFloorService.SpaceFloorServiceClient s = new SpaceFloorService.SpaceFloorServiceClient()) { grv.DataSource = s.GetFloorsByBuildingId(id); tableView.Name = "Rooms"; tableView.DataMember = "Rooms"; } break; case "SpaceFloors": using (SpaceRoomService.SpaceRoomServiceClient s = new SpaceRoomService.SpaceRoomServiceClient()) { grv.DataSource = s.GetRoomByFloorId(id); } break; default: throw new Exception("Unable to identify Entity."); } grv.MasterTableView.DetailTables.Clear(); grv.MasterTableView.DetailTables.Add(tableView); GridTableView tab = new GridTableView(grv); switch (tableView.Name) { case "Buildings": tab.DataMember = "Floors"; tab.Name = "Floors"; tableView.DetailTables.Clear(); tableView.DetailTables.Add(tab); break; case "Floors": tab.DataMember = "Rooms"; tab.Name = "Rooms"; tableView.DetailTables.Clear(); tableView.DetailTables.Add(tab); break; default: break; } if (tableView.Name == "Buildings") { GridTableView subTab = new GridTableView(grv); if (tab.Name == "Floors") { subTab.DataMember = "Rooms"; subTab.Name = "Rooms"; tab.DetailTables.Clear(); tab.DetailTables.Add(subTab); } } grv.DataBind(); }protected void grv_ItemCommand(object sender, GridCommandEventArgs e) { BindDetails(ParentEntity.ParentEntityId); HttpContext.Current.Session["id"] = ParentEntity.ParentEntityId; switch (Session["type"].ToString()) { case "All Categories": FormExtenderControl1.EntityType = new BaseEntities(BaseEntities.SpaceCategories); break; case "SpaceCategories": FormExtenderControl1.EntityType = new BaseEntities(BaseEntities.SpaceBuildings); break; case "SpaceBuildings": FormExtenderControl1.EntityType = new BaseEntities(BaseEntities.SpaceFloors); break; case "SpaceFloors": FormExtenderControl1.EntityType = new BaseEntities(BaseEntities.SpaceRooms); break; default: throw new Exception("Unable to identify Entity."); } clickedType = Session["type"].ToString(); if (e.CommandName == "Modify") { btnSave.CommandName = "Modify"; int id = GetID(); FormExtenderControl1.EntityPrimaryKeyId = id; FormExtenderControl1.DataBind(); mdlPopup.Show(); } if (e.CommandName == "Delete") { int id = GetID(); FormExtenderControl1.Delete(id); BindData(); } if (e.CommandName == "Add") { btnSave.CommandName = "Add"; FormExtenderControl1.EntityPrimaryKeyId = -1; FormExtenderControl1.DataBind(); mdlPopup.Show(); } } private Int32 GetID() { foreach (GridDataItem dataItem in grv.MasterTableView.DetailTables.OwnerGrid.Items) { if (dataItem.Selected == true) { Int32 ID = Int32.Parse(dataItem["Id"].Text); return ID; } } throw new ArgumentNullException("Id Not found"); }thanks
Rohan