Hi
What I am try doing might not be possible or sensible.
I am building a dynamic grid page to edit / insert/ delete data from an unknown tablename with an unknown number of fields (except at render time).
I know that all of my field are one of two types, either a numeric or a string which is often entered multiple times.
I build the columns / insert / edit SQL dynamically and I have the basics working.
I want my "string" columns to appear in the insert / edit (inline) form as a combo box to allow them to type customer text or select from a list of existing items (populated as a distinct list of all previous data entered).
Problem 1: I have changed the BoundColumn to a griddropdown, but now on view mode of the grid the field values are empty (were fine with boundcolumn) but the combo appears on clicking insert.
Problem 2: Can I allow customtext in a griddropdowncolumn? if so how do I do this.
Problem 3: I can't work out how to populate the combo with the preset values. Is it possible to bind to a datareader in code or is my approach wrong?
Below is my code running in page_load. "Case 6" is the problem area. case 6 means that the column is a string and should use the dropdown.
Thanks in advance.
Johnathan
What I am try doing might not be possible or sensible.
I am building a dynamic grid page to edit / insert/ delete data from an unknown tablename with an unknown number of fields (except at render time).
I know that all of my field are one of two types, either a numeric or a string which is often entered multiple times.
I build the columns / insert / edit SQL dynamically and I have the basics working.
I want my "string" columns to appear in the insert / edit (inline) form as a combo box to allow them to type customer text or select from a list of existing items (populated as a distinct list of all previous data entered).
Problem 1: I have changed the BoundColumn to a griddropdown, but now on view mode of the grid the field values are empty (were fine with boundcolumn) but the combo appears on clicking insert.
Problem 2: Can I allow customtext in a griddropdowncolumn? if so how do I do this.
Problem 3: I can't work out how to populate the combo with the preset values. Is it possible to bind to a datareader in code or is my approach wrong?
Below is my code running in page_load. "Case 6" is the problem area. case 6 means that the column is a string and should use the dropdown.
Thanks in advance.
Johnathan
' build grid Dim FieldListList As SqlDataReader = kpiSQL.getReader("select * from dbo.kpi_QuantityColumn where tableid=" & tableid.ToString) While FieldListList.Read Select Case FieldListList("fielddataType") Case 6 ' is a string column Dim boundColumn As GridDropDownColumn boundColumn = New GridDropDownColumn() boundColumn.EmptyListItemText = "--type or choose--" ' allowcustomtext??? boundColumn.UniqueName = FieldListList("FieldName") boundColumn.DataField = FieldListList("FieldName") boundColumn.DropDownControlType = GridDropDownColumnControlType.RadComboBox boundColumn.HeaderText = FieldListList("FieldName") boundColumn.HeaderStyle.Wrap = False Dim presetReader As SqlDataReader = kpiSQL.getReader("SELECT DISTINCT " & FieldListList("FieldName") & " FROM " & thisTable.dbTableName) ' ???? how do I bind the combo to presetReader? RadGrid1.MasterTableView.Columns.Add(boundColumn)
Case Else ' is a numeric column Dim boundColumn As GridNumericColumn boundColumn = New GridNumericColumn() RadGrid1.MasterTableView.Columns.Add(boundColumn) boundColumn.UniqueName = FieldListList("FieldName") boundColumn.DataField = FieldListList("FieldName") Dim prefix As String = "" If Not IsDBNull(FieldListList("prefix")) And FieldListList("FieldName") <> "" Then prefix = " (" & FieldListList("prefix") & ")" End If boundColumn.HeaderText = FieldListList("FieldName") + prefix boundColumn.HeaderStyle.Wrap = False boundColumn.DataFormatString = "{0:N" & FieldListList("NumberOfDps") & "}" End SelectEnd While