English 中文(简体)
如何删除数据库浏览量,因为数据浏览量被删除。
原标题:how to delete database row as DataGrid row is deleted in wpf?

我在我的羊肉项目中有一个数据集,该项目受一个数据来源的约束,并成功地掌握了价值。 现在的问题是,当用户删除一行时,如何作出反应。 我也希望删除数据库中的同一行文。 我的做法是从<代码>lbId中获取。 在目前选定的行文栏中,当用户在关键板或“<代码>上删除纽顿”时,即发布DELETE查询。 如何这样做?

或者,在Winforms,DataGridView上,是否有任何东西,如<密码>。

这里是XAML

 <DataGrid AutoGenerateColumns="False" Height="430" HorizontalAlignment="Left" Margin="378,61,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="550" ItemsSource="{Binding Path=LocalBookmarks}" CanUserReorderColumns="False" CanUserSortColumns="False" Grid.Row="5" RowEditEnding="datagrid1_RowEditEnding" DataGridRow.Selected="datagrid1_RowSelected">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Id" Width="20" Binding="{Binding Path=lbId}" CanUserResize="False"></DataGridTextColumn>
            <DataGridTextColumn Header="Title" Width="225" Binding="{Binding Path=TitleOfPage}" MaxWidth="250" CanUserResize="True"></DataGridTextColumn>
            <DataGridHyperlinkColumn CanUserResize="True" Header="Link" MaxWidth="300" MinWidth="250" Binding="{Binding Path=SiteAddress}"/>
            <DataGridTextColumn Header="Saved On" Width="70" Binding="{Binding Path=DateAdded}" CanUserResize="True"></DataGridTextColumn>
        </DataGrid.Columns>
    </DataGrid>

Here is the image of DataGrid. And just in case the image helps, here it is

这里是具有约束力的法典:

private void BindToData(SqlCeConnectionManger s, int gt, int lt)
    {
        SqlCeDataAdapter sda = new SqlCeDataAdapter("SELECT * FROM LocalBookmarks WHERE lbId > " + gt.ToString() + " AND lbId < " + lt.ToString() + " ORDER BY DateAdded DESC", s.SqlCeCon);
        DataSet dataset = new DataSet();
        sda.Fill(dataset, "LocalBookmarks");
        dataGrid1.DataContext = dataset;
        s.SqlCeCon.Close();     

    }

任何帮助都将受到赞赏。

问题回答

您是否尝试添加一栏,内有一顿。 纽伦将具备能够确定关键参数的参数。 然后将 but子用于验证,从名单上删除,从数据库中删除,然后更新数据网。 我使用了#和 X,但没有背后法。 核对“财产名称”。

我来到这里是为了寻找其他东西相对较晚的张贴/回答。

Sub dg_RowEditEnding(sender As Object, e As DataGridRowEditEndingEventArgs) Handles dg.RowEditEnding

This is the event I use to sync my datagrids with the database backend...

如果您将数据集/数据表捆绑起来,如果使用点击“Del”也会自动从数据集/数据表中删除。

all you have to do then is to call Update on your TabelAdapter to get the changes to your database.

EDIT: btw you can call "RejectChanges" to get the deleted rows back as long you did not call AcceptChanges.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签