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

RadGrid and Update in Database ( Datasource Object )

1 Answer 75 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Ernandes asked on 02 Mar 2009, 12:38 PM
Hi there,
I am using RadGrid however, I am having difficulties to make it update the information of the Database.

The scenario I have is this:

I created a DataSource object and a class with the components (insert, select, delete and update)

[DataObjectMethod (DataObjectMethodType.Select)]
[DataObjectMethod (DataObjectMethodType.Insert)]
[DataObjectMethod (DataObjectMethodType.Update)]
[DataObjectMethod (DataObjectMethodType.Delete)]

I made reference to the component, and Select functions correctly, but not the other operations.

In a key MasterTableView registered: datakeynames = "id_menu_esquerdo" which is my primary key in the Database, but when I try to change something, nothing happens, what can be wrong?
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"  
        AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"  
        DataSourceID="ObjectDataSource1" GridLines="None"
<MasterTableView autogeneratecolumns="False" clientdatakeynames="id_menu_esquerdo"  
            datakeynames="id_menu_esquerdo" datasourceid="ObjectDataSource1"
<RowIndicatorColumn Visible="False"
<HeaderStyle Width="20px"></HeaderStyle> 
<ExpandCollapseColumn Visible="False" Resizable="False"
<HeaderStyle Width="20px"></HeaderStyle> 
        <telerik:GridBoundColumn DataField="id_menu_esquerdo" DataType="System.Int32"  
            HeaderText="id_menu_esquerdo" SortExpression="id_menu_esquerdo"  
        <telerik:GridBoundColumn DataField="Nome_menu_esquerdo"  
            HeaderText="Nome_menu_esquerdo" SortExpression="Nome_menu_esquerdo"  
        <telerik:GridBoundColumn DataField="menu_esquerdo_link"  
            HeaderText="menu_esquerdo_link" SortExpression="menu_esquerdo_link"  
        <telerik:GridBoundColumn DataField="menu_esquerdo_ordem"  
            DataType="System.Int32" HeaderText="menu_esquerdo_ordem"  
            SortExpression="menu_esquerdo_ordem" UniqueName="menu_esquerdo_ordem"
<PopUpSettings ScrollBars="None"></PopUpSettings> 


        public static void AlterarItemMenuE(ItensMenu_E_Modelos ItensMenu) 
            using (SqlConnection conn = Banco.ObterConexao()) 
                using (SqlCommand cmd = new SqlCommand("UPDATE [tbl_web_MenuE] set Nome_menu_esquerdo = @Nome_menu_esquerdo, menu_esquerdo_ordem = @menu_esquerdo_ordem, menu_esquerdo_link = @menu_esquerdo_link WHERE id_menu_esquerdo = @id_menu_esquerdo", conn)) 
                    cmd.Parameters.AddWithValue("@id_menu_esquerdo", Convert.ToInt32(ItensMenu.id_menu_esquerdo)); 
                    cmd.Parameters.AddWithValue("@Nome_menu_esquerdo", Convert.ToString(ItensMenu.Nome_menu_esquerdo)); 
                    cmd.Parameters.AddWithValue("@menu_esquerdo_ordem", Convert.ToInt32(ItensMenu.menu_esquerdo_ordem)); 
                    cmd.Parameters.AddWithValue("@menu_esquerdo_link", Convert.ToString(ItensMenu.menu_esquerdo_link)); 

when I use the DataGridView's own VisualStudio everything works correctly, would help one to use the resources of the RadGrid
Best Regards

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 05 Mar 2009, 07:20 AM
Hello Ernandes,

I reviewed the code and it looks correct. However, if the issue persists, you can open a formal support ticket, and send us a small working project, demonstrating your setup, and the discrepancy at hand, for additional testing.

Sincerely yours,
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question