Developer forum

Forum » Development » EditableGrid - Using LINQ data source

EditableGrid - Using LINQ data source

Diogo Lino
Reply
Hello,

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
 




Replies

 
Nuno Aguiar
Reply
 Hi,

It seems like an error in the Dynamicweb Control. Can your guys verify this? We really need a workaround for this.

Best Regards,
Nuno
 
Pavel Volgarev
Reply
This post has been marked as an answer
Hi Diogo an Nuno,

Although EditableGrid was supposed to be an extension of a standard ASP.NET GridView control (in a way that it would allow adding new rows dynamically without refreshing the entire page, managing the existing rows more efficiently plus some other minor improvements) it doesn't support all its features. For example, there are some problems with paging, sorting and row commands.

We have no plans of fixing the issues mentioned above now so my suggestion would be to use GridView instead. Diogo, according to the markup snippets you provided you will need to make only one change - replace "dw:EditableGrid" with "asp:GridView" and recompile.

-- Pavel


Votes for this answer: 0
 
Nuno Aguiar
Reply
 Hi Pavel,

Thanks for that. We will get it working and get back to you.
Note to self: avoid editable grids :P

Nuno

 

You must be logged in to post in the forum