datarowview

Get SelectedItems from database fed ListBox

▼魔方 西西 提交于 2020-01-04 13:11:55
问题 I need to get values from selected items from listbox which is binding from database. But if I try listBoxAtribute.SelectedItems[0].ToString() it returns System.Data.DataRowView Is there any way to convert Data from DataRowView to string ? My idea looks like this: for(int i = 0; i < listBoxAtribute.SelectedItems.Count; i++) { MessageBox.Show(listBoxAtribute.SelectedItems[i].Tostring); } Thanks a lot for any reply. 回答1: Try casting selected item of listbox to DataRowItem first and access

How Can Convert DataRow to DataRowView in c#

北战南征 提交于 2019-12-30 06:04:20
问题 Can or how to convert DataRow to DataRowView? For example: DataTable dt=ds.Tables[0]; DataRow dr= dt.NewRow(); DataRowView drv = ???? 回答1: Use DataTable dt=ds.Tables[0]; DataRow dr= dt.NewRow(); DataRowView drv= dt.DefaultView[dt.Rows.IndexOf(dr)]; 回答2: The above method does not work if the DataRow status is Detached. This code snippet could be used in such case: DataRow dRow = dataTable.NewRow(); //... DataRowView dRowView = dRow.Table.DefaultView.AddNew(); for (int i = 0; i < dRow.ItemArray

How Can Convert DataRow to DataRowView in c#

一个人想着一个人 提交于 2019-12-30 06:04:14
问题 Can or how to convert DataRow to DataRowView? For example: DataTable dt=ds.Tables[0]; DataRow dr= dt.NewRow(); DataRowView drv = ???? 回答1: Use DataTable dt=ds.Tables[0]; DataRow dr= dt.NewRow(); DataRowView drv= dt.DefaultView[dt.Rows.IndexOf(dr)]; 回答2: The above method does not work if the DataRow status is Detached. This code snippet could be used in such case: DataRow dRow = dataTable.NewRow(); //... DataRowView dRowView = dRow.Table.DefaultView.AddNew(); for (int i = 0; i < dRow.ItemArray

How can I get the string value of a checked item from a CheckedListBox?

浪尽此生 提交于 2019-12-24 11:46:12
问题 I've got this code to try to extract the display value from a CheckedListBox: CheckedListBox.CheckedItemCollection selectedUnits = checkedListBoxUnits.CheckedItems; _selectedUnit = selectedUnits[0].ToString(); ...but it doesn't work - the value of "_selectedUnit", instead of being " platypus " as it should be, is " System.Data.DataRowView ". How can I coax the string value out of this complex object? UPDATE I'm not sure just what user2946329 wants to see bzg. my CheckedListBox, but here is

c# Set value to a DataRow automatically

烈酒焚心 提交于 2019-12-11 22:17:21
问题 What I want to do is to change value of row's forth cell if cell number 3 is changed. I have an EditEnding method for my grid. That's my method below. I don't really know how to finish it that's the grid definition: <DataGrid x:Name="dataGrid1"... CellEditEnding="dataGrid1_EditEnding"> and the method: private void dataGrid1_EditEnding(object sender, DataGridCellEditEndingEventArgs e) { // initializing DataRowView from my datagrid DataRowView drv = (DataRowView)dataGrid1.CurrentItem; //

A way to get a DataRow from a DataRowView

筅森魡賤 提交于 2019-12-11 10:39:25
问题 I'm currently trying to get the content of a selected row in a DataGrid. The problem is that I actually get a DataRowView but I can't do anything with it... I would like to acces to all the field of my selected row in my DataGrid. Here's the code to help you : XAML : <DataGrid SelectionUnit="FullRow" SelectedItem="{Binding SelectedZone, Mode=TwoWay}" AutoGenerateColumns="True" Margin="0,167,6,24" Name="existingCase" Width="780" > <DataGrid.RowStyle> <Style TargetType="{x:Type DataGridRow}">

Get the DefaultView DataRowView from a DataRow

情到浓时终转凉″ 提交于 2019-12-10 03:45:43
问题 Here's the situation: I need to bind a WPF FixedPage against a DataRow . Bindings don't work against DataRows ; they work against DataRowViews . I need to do this in the most generic way possible, as I know nothing about and have no control over what is in the DataRow . What I need is to be able to get a DataRowView for a given DataRow . I can't use the Find() method on the DefaultView because that takes a key, and there is no guarantee the table will have a primary key set. Does anybody have

How Can Convert DataRow to DataRowView in c#

半世苍凉 提交于 2019-11-30 17:51:22
Can or how to convert DataRow to DataRowView? For example: DataTable dt=ds.Tables[0]; DataRow dr= dt.NewRow(); DataRowView drv = ???? BizApps Use DataTable dt=ds.Tables[0]; DataRow dr= dt.NewRow(); DataRowView drv= dt.DefaultView[dt.Rows.IndexOf(dr)]; The above method does not work if the DataRow status is Detached. This code snippet could be used in such case: DataRow dRow = dataTable.NewRow(); //... DataRowView dRowView = dRow.Table.DefaultView.AddNew(); for (int i = 0; i < dRow.ItemArray.Length; i++) { dRowView.Row[i] = dRow[i]; } DataRowView selecRow = dataTable.DefaultView.Cast