Hi,
I'm trying to do something that I thought should be very simple...but I just can't get past one little issue. After spending several hours checking out old postings and demo, I'm still at a lost. Here's the description:
1. I have a simple grid with 4 columns: Article ID, article Name, Supplier ID and Supplier. The grid columns are auto-generated based on a dataset retrieved at run time. The Article ID and Supplier ID column are made invisible and readonly during the ItemCreated event. The grid displays correctly.
2. I'm using an edit form, which is automatically generated. AutoGenerateEditColumn = "true"
3. When the edit form opens, it displays 2 textboxes: one for Article Name and one for Supplier.
4. What I'd like to do is simply change the Supplier textbox to a radComboBox. The combobox will display a number of suppliers so user can choose one.
5. I'm able to at itemDataBound time make the Supplier textbox invisible and add a radComboBox control to the edit form. The radComboBox is bound to a dataset at the same time.
6. The edit form displays correctly with the Article Name textbox and a Supplier radcombobox. I can make changes as needed.
7. However, when I click the Update button, which fires off the UpdateCommand, I'm not able to access the Supplier RadComboBox in the Edit Form to extract the new value selected by the user. The control is no where to be found.
Attached are some code snippets...it has got to be something simple I overlooked. I would appreciate it very much if someone can offer some advise...as this is putting a screeching halt on the project.
Thanks.
Barry
Code to add RadComboBox to Edit Form at ItemDataBound event:
Code to extract the RadComboBox control from the Edit Form; but finds nothing!!!
I'm trying to do something that I thought should be very simple...but I just can't get past one little issue. After spending several hours checking out old postings and demo, I'm still at a lost. Here's the description:
1. I have a simple grid with 4 columns: Article ID, article Name, Supplier ID and Supplier. The grid columns are auto-generated based on a dataset retrieved at run time. The Article ID and Supplier ID column are made invisible and readonly during the ItemCreated event. The grid displays correctly.
2. I'm using an edit form, which is automatically generated. AutoGenerateEditColumn = "true"
3. When the edit form opens, it displays 2 textboxes: one for Article Name and one for Supplier.
4. What I'd like to do is simply change the Supplier textbox to a radComboBox. The combobox will display a number of suppliers so user can choose one.
5. I'm able to at itemDataBound time make the Supplier textbox invisible and add a radComboBox control to the edit form. The radComboBox is bound to a dataset at the same time.
6. The edit form displays correctly with the Article Name textbox and a Supplier radcombobox. I can make changes as needed.
7. However, when I click the Update button, which fires off the UpdateCommand, I'm not able to access the Supplier RadComboBox in the Edit Form to extract the new value selected by the user. The control is no where to be found.
Attached are some code snippets...it has got to be something simple I overlooked. I would appreciate it very much if someone can offer some advise...as this is putting a screeching halt on the project.
Thanks.
Barry
Code to add RadComboBox to Edit Form at ItemDataBound event:
| Protected Sub fabricGrid_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles fabricGrid.ItemDataBound |
| If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then |
| Dim editedItem As GridEditFormItem = CType(e.Item, GridEditFormItem) |
| ' Add supplier combobox |
| Dim supplierCombo As New RadComboBox |
| supplierCombo.ID = "supplierCombo" |
| Dim objPlan As New lucyPlanBizObject.plan _ |
| (Application("ConnectString")) |
| Dim dsResult As DataSet |
| dsResult = objPlan.getFabricSupplier("active") |
| supplierCombo.DataSource = dsResult.Tables(0) |
| supplierCombo.DataValueField = "fabricSupplierID" |
| supplierCombo.DataTextField = "supplier" |
| supplierCombo.DataBind() |
| supplierCombo.SelectedValue = 2 |
| editedItem("supplier").Controls.Add(supplierCombo) |
| Dim textbox As TextBox |
| textbox = CType(editedItem("supplier").Controls(0), TextBox) |
| textbox.Visible = False |
| textbox.CssClass = "smalltext" |
| End If |
| End Sub |
Code to extract the RadComboBox control from the Edit Form; but finds nothing!!!
| Protected Sub fabricGrid_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles fabricGrid.UpdateCommand |
| Dim i As Integer |
| If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then |
| Dim editedItem As GridEditFormItem = CType(e.Item, GridEditFormItem) |
| Dim textbox As TextBox |
| Dim supplierCombo As RadComboBox |
| Dim fabricID As String |
| Dim planStyleColorFabricID As Integer |
| Dim fabricSupplierID As Integer |
| planStyleColorFabricID = CInt(e.Item.OwnerTableView.Items(e.Item.ItemIndex).Cells(3).Text) |
| fabricID = e.Item.OwnerTableView.Items(e.Item.ItemIndex).Cells(4).Text |
| fabricSupplierID = CInt(e.Item.OwnerTableView.Items(e.Item.ItemIndex).Cells(6).Text) |
| textbox = CType(editedItem("fabricID").Controls(0), TextBox) |
| supplierCombo = CType(editedItem("supplier").Controls(1), RadComboBox) 'supplierCombo = nothing because RadComboBox control is nowhere to be found!!! |
| End If |
| End Sub |