This is a migrated thread and some comments may be shown as answers.

RadGridView disabling add/delete/edit rows

3 Answers 347 Views
GridView
This is a migrated thread and some comments may be shown as answers.
dalexsoto
Top achievements
Rank 1
dalexsoto asked on 18 May 2011, 09:23 PM
Hi im using entity framework to bind the datasource of a RadGridView

private void cmbUsers_SelectedValueChanged(object sender, EventArgs e)
       {
           cmbUsers.ValueMember = "Id";
           var resguardos = from e1 in context.tblBienes
                                        where e1.IdResponsable == (long)cmbUsuarios.SelectedValue
                                        select new
                                        {
                                            Id = e1.IdBien,
                                            Descripcion = e1.descripcion,
                                            Estado = e1.estado,
                                            Placa_Anterior = e1.placaAnterior,
                                            Placa_Nueva = e1.placaNueva,
                                            Ubicacion = e1.ubicacion,
                                            Fecha_De_Asignacion = e1.fechaAsignacion,
                                            Etiqueta = e1.etiqueta,
                                            Procuraduria = context.tblProcuradurias.Where(e2 => (e2.IdProcuraduria == (long)cmbProcuradurias.SelectedValue)).Select((e2 => e2.ciudad)).FirstOrDefault()
                                        };
           rgvResguardos.DataSource = resguardos;
       }

rgvResguardos its a DataGridView and the result of the linq to entities its being given as datasource to it. i enabled Ading and enabled Editing on rgvResguardos but when i run my app it displays data but it doesnt allow me to add new rows nor editing or deleteing.

is there any way to enable this options? i know i have to take care of inserting, deleteing and updating info on the database.

3 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 20 May 2011, 08:59 AM
Hello,

This happens because you are using Anonymous types, please create a concrete type and it will work as expected, and if possible create a BindingList<T> and bind that to the grid (for INotifyPropertyChanged).

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
Hannah
Top achievements
Rank 2
answered on 17 May 2013, 06:32 PM
Can we force the Add Row to display and handle it ourselves in some manner while still using the dynamic or object datatypes as our datasource?

CORRECTION: Nevermind, I had the ReadOnly flag set.  *facepalm*  It appears that dynamic datatypes still allow editing...as far as I can tell so far...
0
Peter
Telerik team
answered on 22 May 2013, 05:07 PM
Hello Wayne,

I am happy that you found a solution for this. Should you have any other questions, do not hesitate to ask.

Regards,
Peter
Telerik
RadChart for WinForms is obsolete. Now what?
Tags
GridView
Asked by
dalexsoto
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Hannah
Top achievements
Rank 2
Peter
Telerik team
Share this question
or