-
Jul 7th, 2016, 05:54 AM
#1
-
Jun 20th, 2017, 05:15 AM
#2
Addicted Member
Re: WPF DataGrid Check/Uncheck All Functionality
KGComputers
if uncheck 5 from 100 is there any way to loop throw checked only
pessdo code
if is checked then
update table
else
{
}
-
Jun 20th, 2017, 03:28 PM
#3
Addicted Member
Re: WPF DataGrid Check/Uncheck All Functionality
this error appear
An unhandled exception of type 'System.InvalidCastException' occurred in WpfDatagridCheckAllHeader.exe
Additional information: Unable to cast object of type '<>f__AnonymousType0`2[System.String,System.String]' to type 'System.Data.DataRowView'.
in this code
DataRowView rv = (DataRowView)r.Item;
Code:
private void SetCheckbox(IEnumerable<DataGridRow> row, bool value)
{
foreach (DataGridRow r in row)
{
DataRowView rv = (DataRowView)r.Item;
foreach (DataGridColumn column in dgProducts.Columns)
{
if (column.GetType().Equals(typeof(DataGridTemplateColumn)))
{
rv.Row["Discontinue"] = value;
//LINQ or Database Method to Update Product discontinue status
Connections.UpdateProductDiscontinue(value, rv.Row["productname"].ToString());
}
}
}
-
Jun 25th, 2017, 11:49 AM
#4
Re: WPF DataGrid Check/Uncheck All Functionality
Try checking r.Item if it's not null.
C# Code:
if(r.item != null) { DataRowView rv = (DataRowView)r.Item; foreach (DataGridColumn column in dgProducts.Columns) { //... } }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|