I can't figure this out. I have a RadComboBox inside a GridTemplateColumn with Items for commands. When a command is selected from the DropDownList it posts back.
This Fires the selected command. Which is processed by this code.
This code is sent here to bind the UserControl appropriate for the selected command.
The Error Comes at this line where it states "invalid index". The e.Item.ItemIndex is -1.
The issue is when I use the "FireCommandEvent" function, it doesn't set the ItemIndex.
How do I fix this?
protected void gvTransactionsCommandList_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { RadComboBox myBox = (RadComboBox)sender; if (myBox != null && !string.IsNullOrEmpty(myBox.SelectedValue.Trim())) { GridDataItem item = (GridDataItem)myBox.NamingContainer; RadGrid grid = (RadPane1.FindControl("gvTransactions") as RadGrid); gvTransactions.MasterTableView.Items[item.ItemIndex].Selected = true; (grid.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem).FireCommandEvent(myBox.SelectedValue, string.Empty); } }This Fires the selected command. Which is processed by this code.
protected void gvTransactions_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { switch (e.CommandName) { case "InitInsert": gvTransactions.SetInsertControl("UserControls/TransactionDetails.ascx"); break; case "RowClick": gvTransactions.SetUpdateControl("UserControls/TransactionDetails.ascx", e); break; case "ViewProcess": gvTransactions.SetUpdateControl("UserControls/TransactionDetails.ascx", e); break; case "PerformInsert": UserControl userControl = gvTransactions.GetInsertControl(e); break; case "PerformUpdate": DataTable dtOld = StoredProcedure.ReturnData("spPeople_AppointmentManager_Get", "@TransactionID", gvTransactions.GetKeyValue(e)); UserControl userUpdateControl = gvTransactions.GetUpdateControl(e); gvTransactions.CloseUpdateControl(e); break; case "PerformDelete": StoredProcedure.RunCommand("spPeople_AppointmentManager_Delete", "@AcademicID", gvTransactions.GetKeyValue(e)); gvTransactions.CloseUpdateControl(e); break; } }This code is sent here to bind the UserControl appropriate for the selected command.
public static void SetUpdateControl(this RadGrid control, string userControlName, GridCommandEventArgs e) { control.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.WebUserControl; control.MasterTableView.EditFormSettings.UserControlName = userControlName; control.MasterTableView.EditFormSettings.EditColumn.UniqueName = "EditFormControl"; control.MasterTableView.Items[e.Item.ItemIndex].Edit = true; control.MasterTableView.Rebind(); }The Error Comes at this line where it states "invalid index". The e.Item.ItemIndex is -1.
control.MasterTableView.Items[e.Item.ItemIndex].Edit = true;The issue is when I use the "FireCommandEvent" function, it doesn't set the ItemIndex.
How do I fix this?