从datagrid将数据插入数据库 [英] Insert data into database from datagrid

查看:189
本文介绍了从datagrid将数据插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我的数据网格中有多行。



请告诉我怎么样在数据库中插入datagrid值。



谢谢你

Hi all

I have multiple rows in my datagrid.

Please tell me how to insert the datagrid value inside database.

Thank you

推荐答案

不,不是因为wpf它是针对windows的app



对于WPF DataGrid



No it's not for wpf it's for windows app

For WPF DataGrid

foreach (DataGridRow  row in DataGrid.Rows)
           {

 //DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0]);
        if (row != null)
        {
            DataGridCellsPresenter presenter = GetVisualChild<datagridcellspresenter>(row);
            // find grid cell object for the cell with index 0
            DataGridCell cell = presenter.ItemContainerGenerator.ContainerFromIndex(0) as DataGridCell;
            if (cell != null)
            {
                Console.WriteLine(((TextBlock)cell.Content).Text);
            }
        }
}


这篇关于从datagrid将数据插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆