xjgs_xhj@163.com
Top achievements
Rank 1
xjgs_xhj@163.com
asked on 05 Oct 2010, 01:59 PM
How to update a cell(type of System.Byte[]) when its value is System.DBNull?
My VB code raise an error:
Dim buffer() As Byte
Dim fsBLOBFile As FileStream = New FileStream("C:\X.Y", FileMode.Open)
buffer = New Byte(fsBLOBFile.Length - 1) {}
fsBLOBFile.Read(buffer, 0, CInt(fsBLOBFile.Length))
Me.RadGridView1.Rows(1).Cells(1).Value = buffer 'Rows(1).Cells(1) is null and collum(1) is System.Byte[] type.
My VB code raise an error:
Dim buffer() As Byte
Dim fsBLOBFile As FileStream = New FileStream("C:\X.Y", FileMode.Open)
buffer = New Byte(fsBLOBFile.Length - 1) {}
fsBLOBFile.Read(buffer, 0, CInt(fsBLOBFile.Length))
Me.RadGridView1.Rows(1).Cells(1).Value = buffer 'Rows(1).Cells(1) is null and collum(1) is System.Byte[] type.
7 Answers, 1 is accepted
0
Emanuel Varga
Top achievements
Rank 1
answered on 05 Oct 2010, 04:03 PM
Hello,
It depends on a couple of factors, 1, is the grid bounded = then you can update the underlying databound item directly;
If it's not bounded, it depends on the type of column you are using.
Please answer this question, and i will try to help,
Best Regards,
Emanuel Varga
It depends on a couple of factors, 1, is the grid bounded = then you can update the underlying databound item directly;
If it's not bounded, it depends on the type of column you are using.
Please answer this question, and i will try to help,
Best Regards,
Emanuel Varga
0
Emanuel Varga
Top achievements
Rank 1
answered on 05 Oct 2010, 04:39 PM
Hello again,
It is updating the value when you set it with the .Value property, but this value will not be displayed in the grid, here is a sample of how to do this, with both business objects and data table data sources
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
It is updating the value when you set it with the .Value property, but this value will not be displayed in the grid, here is a sample of how to do this, with both business objects and data table data sources
Imports SystemImports System.ComponentModelImports System.DataImports System.Windows.FormsImports Telerik.WinControls.UIPublic Class Form1 Private radGridView1 As New RadGridView() Private WithEvents changeValueButton As New RadButton() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill radGridView1.Dock = DockStyle.Fill Me.Controls.Add(radGridView1) changeValueButton.Text = "Change value" changeValueButton.Dock = DockStyle.Bottom Me.Controls.Add(changeValueButton) Me.BindToDataTable() 'this.BindToBussinessObjects(); End Sub Private Sub changeValueButton_Click(ByVal sender As Object, ByVal e As EventArgs) If radGridView1.CurrentCell Is Nothing OrElse radGridView1.CurrentColumn.Name <> "Bytes" Then Return End If Dim currentCell = radGridView1.CurrentCell currentCell.Value = New Byte() {2, 3} End Sub Private Sub BindToBusinessObjects() Me.radGridView1.DataSource = New TestsCollection(10) End Sub Private Sub BindToDataTable() Dim table As New DataTable() table.Columns.Add("Id", GetType(Integer)) table.Columns.Add("Bytes", GetType(Byte())) table.Rows.Add(25, Nothing) table.Rows.Add(50, Nothing) table.Rows.Add(10, Nothing) table.Rows.Add(21, New Byte() {2, 3}) table.Rows.Add(100, Nothing) Me.radGridView1.DataSource = table End SubEnd ClassPublic Class Test Public Property Id() As Integer Get Return m_Id End Get Set(ByVal value As Integer) m_Id = value End Set End Property Private m_Id As Integer Public Property Bytes() As Byte() Get Return m_Bytes End Get Set(ByVal value As Byte()) m_Bytes = value End Set End Property Private m_Bytes As Byte() Public Sub New(ByVal id As Integer, ByVal bytes As Byte()) Me.Id = id Me.Bytes = bytes End SubEnd ClassPublic Class TestsCollection Inherits BindingList(Of Test) Public Sub New(ByVal noItems As Integer) For i As Integer = 1 To noItems - 1 Me.Add(New Test(i, Nothing)) Next End SubEnd ClassHope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0
xjgs_xhj@163.com
Top achievements
Rank 1
answered on 05 Oct 2010, 04:55 PM
My GridView is bounded to a dataset.I just want to save a file to the cell.It raise an 'ArgumentNullException' error at line '
currentCell.Value = New Byte() {2, 3}.'0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 05 Oct 2010, 05:18 PM
Hello again,
Which version of Telerik controls are you using, the example I've provided is tested and working under Q2 2010 SP2, please update to this version if you can and let me know if everything is working.
Best Regards,
Emanuel Varga
Which version of Telerik controls are you using, the example I've provided is tested and working under Q2 2010 SP2, please update to this version if you can and let me know if everything is working.
Best Regards,
Emanuel Varga
0
xjgs_xhj@163.com
Top achievements
Rank 1
answered on 06 Oct 2010, 01:49 PM
I'm using Q2 2010 SP1.When I use 'EMP_PHOTO_DataSet.EMP_PHOTO.Rows(4)("PICTURE") = buffer',it works.But then I have to apply changes to the backend database and fill data back to GridView.What I want is to save files to their cells and apply them to database all together.
0
xjgs_xhj@163.com
Top achievements
Rank 1
answered on 06 Oct 2010, 02:10 PM
It works under Q2 2010 SP2.Thank you.
0
Emanuel Varga
Top achievements
Rank 1
answered on 06 Oct 2010, 02:11 PM
Hello,
Glad to be able to help,
If you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Glad to be able to help,
If you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga