I have a grid that is adding combo boxes to the autogenerated header rows and when
the user clicks a button on the page I will need to determine what they selected in these combo boxes...
So I have been playing around with a foreach loop and trying to get a hock into the column's header and get the combo's.... Any suggestions?
protected void ValidateButton_Click(object sender, EventArgs e) { // Foreach loop that will need to access the header controls and determine what a user selected in a dynamically injected //combobox...//}Method that populates the Header row with combo boxes
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridHeaderItem) { GridHeaderItem item = e.Item as GridHeaderItem; var columnName = "Column"; var columnCount = 0; foreach (GridColumn col in RadGrid1.MasterTableView.AutoGeneratedColumns) { RadComboBox radCombo = new RadComboBox(); radCombo.ClientIDMode = ClientIDMode.Static; radCombo.ID = "Column" + columnCount; radCombo.EmptyMessage = "Select Field"; //Need to get fields and etc,then loop and add var receiveByTagsFields = GetReceiveByTagFields(Convert.ToInt32(PurchaseShipmentUid)); foreach (var field in receiveByTagsFields.ReceiveByTagImportFields.OrderBy(x => x.Label)) { RadComboBoxItem CBitem = new RadComboBoxItem(); CBitem.ClientIDMode = ClientIDMode.AutoID; CBitem.Text = field.Label; CBitem.Value = field.Id.ToString(); radCombo.Items.Add(CBitem); } if (receiveByTagsFields.MetaFields.Count() != 0) { foreach (var field in receiveByTagsFields.MetaFields.OrderBy(x => x.Label)) { RadComboBoxItem CBitem = new RadComboBoxItem(); CBitem.ClientIDMode = ClientIDMode.AutoID; CBitem.Text = field.Label; CBitem.Value = field.InventoryMetaUid.ToString(); radCombo.Items.Add(CBitem); } } LinkButton link = new LinkButton(); link.ClientIDMode = ClientIDMode.AutoID; link.Text = "Edit"; LiteralControl br = new LiteralControl("<br />"); if (col.ColumnType == "GridBoundColumn" || col.ColumnType == "GridNumericColumn") { item[col.UniqueName].Controls.Add(br); item[col.UniqueName].Controls.Add(radCombo); } radCombo.Items.Add(new RadComboBoxItem("Do not import", "-1")); columnCount++; } } }