I'm trying to use LINQ to SQL to manage data from an EditableGrid.
I have the following code in aspx:
<dw:EditableGrid ID="gridCategories" DataSourceID="gridCategoriesDataSource" DataKeyNames="Id, Lang" runat="server" CssClass="dwGrid" AutoGenerateColumns="false" EnableModelValidation="True" CellPadding="10" PageSize="100" OnRowCommand="gridCategories_RowCommand"> <Columns> <asp:BoundField DataField="Description" HeaderText="Descrição" SortExpression="Description" /> <asp:BoundField DataField="IdProd" HeaderText="Id Produção" SortExpression="IdProd" /> <asp:BoundField DataField="IdDev" HeaderText="Id Desenvolvimento" SortExpression="IdDev" /> <asp:CommandField ButtonType="Image" ShowEditButton="True" ShowCancelButton="True" ShowDeleteButton="True" EditImageUrl="/Admin/Images/Ribbon/Icons/Small/EditDocument.png" UpdateImageUrl="/Admin/Images/Ribbon/Icons/Small/Save.png" CancelImageUrl="/Admin/Images/Ribbon/Icons/Small/Cancel.png" DeleteImageUrl="/Admin/Images/Ribbon/Icons/Small/Delete.png" /> </Columns> </dw:EditableGrid>
<asp:LinqDataSource ID="gridCategoriesDataSource" ContextTypeName="AOLDataContext" TableName="Categories" EnableInsert="True" EnableUpdate="True" EnableDelete="True" runat="server" OnDataBinding="gridCategoriesDataSource_DataBinding" OnInserting="gridCategoriesDataSource_Inserting" OnUpdating="gridCategoriesDataSource_Updating" OnDeleting="gridCategoriesDataSource_Deleting" />
And one example of updating function:
protected void gridCategoriesDataSource_Updating(object sender, LinqDataSourceUpdateEventArgs e) { Categories updatedCategory = (Categories) e.NewObject; // some come in updating }
The database table has a primary key of 2 columns (Id, Lang) as described on DataKeyNames property.
The problem is that i can load the values in the EditableGrid, but when updating, after changing the values and clicking on Save on the EditableGrid row it does not execute the DataSource_Updating function and is not storing the data on the database.
Any idea? Other ways to use LINQ with EditableGrid?
Thanks!
Diogo Lino