views:

722

answers:

3

I bind my DevExpress XtraGrid to a SQL Server database. I use the default navigator to delete rows. I would like the database to reflect these deletions as well. How do I do this?

Erik

A: 

What exactly is your grid's datasource?

Miha Markic
A: 

You should enable the ASPxGridView GridViewCommandColumn.

Here's an example using the Object Datasource but the concept is the same for any type.

<dxwgv:GridViewCommandColumn ShowSelectCheckbox="False" VisibleIndex="0" Caption="Projects">
    <DeleteButton Visible="True">
    </DeleteButton>
    <ClearFilterButton Visible="True"></ClearFilterButton>
</dxwgv:GridViewCommandColumn>

And have the aproppiate Datasource:

<asp:ObjectDataSource ID="MyDS" runat="server" 
        DeleteMethod="Delete"
        TypeName="Model.DataRepository">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int64" />
        </DeleteParameters>
</asp:ObjectDataSource>
JeremySpouken
The question is about XtraGrid (WinForms) not ASPxGridView :-)
Miha Markic
Opps... then you should use DeleteSelectedRows method :)
JeremySpouken
+1  A: 

http://www.devexpress.com/Help/?document=ASPxGridView/DevExpressWebASPxGridViewASPxGridView_RowDeletingtopic.htm

Gary L Cox Jr
Unless OP is mistaken, he is talking about XtraGrid... :-)
Miha Markic
Hate when I do that, I work with both so get them mixed up sometimes... ;)
Gary L Cox Jr