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?
More...
when I use the DataGridView's own VisualStudio everything works correctly, would help one to use the resources of the RadGrid
Best Regards
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> |
</RowIndicatorColumn> |
<ExpandCollapseColumn Visible="False" Resizable="False"> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="id_menu_esquerdo" DataType="System.Int32" |
HeaderText="id_menu_esquerdo" SortExpression="id_menu_esquerdo" |
UniqueName="id_menu_esquerdo"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Nome_menu_esquerdo" |
HeaderText="Nome_menu_esquerdo" SortExpression="Nome_menu_esquerdo" |
UniqueName="Nome_menu_esquerdo"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="menu_esquerdo_link" |
HeaderText="menu_esquerdo_link" SortExpression="menu_esquerdo_link" |
UniqueName="menu_esquerdo_link"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="menu_esquerdo_ordem" |
DataType="System.Int32" HeaderText="menu_esquerdo_ordem" |
SortExpression="menu_esquerdo_ordem" UniqueName="menu_esquerdo_ordem"> |
</telerik:GridBoundColumn> |
</Columns> |
<EditFormSettings> |
<PopUpSettings ScrollBars="None"></PopUpSettings> |
</EditFormSettings> |
</MasterTableView> |
</telerik:RadGrid> |
More...
[DataObjectMethod(DataObjectMethodType.Update)] |
public static void AlterarItemMenuE(ItensMenu_E_Modelos ItensMenu) |
{ |
using (SqlConnection conn = Banco.ObterConexao()) |
{ |
conn.Open(); |
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)); |
cmd.ExecuteNonQuery(); |
} |
} |
} |
when I use the DataGridView's own VisualStudio everything works correctly, would help one to use the resources of the RadGrid
Best Regards