Hello,
I have a problem with RadColorPicker in a RadGrid.
In my code behind :
When I do :
It's works for the display but when i edit the value, the database is not updated.
How can I do?
Thanks in advance
I have a problem with RadColorPicker in a RadGrid.
| <telerik:Radgrid ID="RadGrid1" (...)> |
| (...) |
| <MasterTableView (...)> |
| <EditFormSettings EditformType="Template"> |
| <FormTemplate> |
| (...) |
| <tr> |
| <td> |
| <span>Couleur: </span> |
| </td> |
| <td> |
| <telerik:RadColorPicker ID="RadColorPicker1" runat="server" Preset="Standard" ShowIcon="true" Skin="Black" PaletteModes="All" SelectedColor='<%# HexStringToColor(myCStr(Bind("Couleur"))) %>'> |
| </telerik:RadColorPicker> |
| </td> |
| </tr> |
| (...) |
| </FormTemplate> |
| </EditFormSettings> |
| </MasterTableView> |
| </RadGrid> |
In my code behind :
| Function HexStringToColor(ByVal hex As String) As System.Drawing.Color |
| hex = hex.Replace("#", "") |
| If hex.Length <> 6 Then |
| Throw New Exception(hex & " n'est pas une valeur de couleur hexadecimale valide.") |
| End If |
| Dim r, g, b As String |
| r = hex.Substring(0, 2) |
| g = hex.Substring(2, 2) |
| b = hex.Substring(4, 2) |
| Return System.Drawing.Color.FromArgb(HexStringToBase10Int(r), HexStringToBase10Int(g), HexStringToBase10Int(b)) |
| End Function |
| Function HexStringToBase10Int(ByVal hex As String) As Integer |
| Dim base10value As Integer = 0 |
| Try |
| base10value = System.Convert.ToInt32(hex, 16) |
| Catch ex As Exception |
| base10value = 0 |
| End Try |
| Return base10value |
| End Function |
| Function myCStr(ByVal test As Object) As String |
| If isdbnull(test) Then |
| Return ("#ffffff") |
| Else |
| Return CStr(test) |
| End If |
| End Function |
When I do :
| SelectedColor='<%# HexStringToColor(myCStr(Eval("Couleur"))) %>' |
How can I do?
Thanks in advance