c# - Cannot Edit Cells in RadGridView Telerik WPF -


i using telerik's radgridview display data database. data want load gridview , added 3 columns users type in additional information.

the problem i'm having when type in information 1 of empty cells , click out of row/column, information i've typed in disappears. i've scoured every forum relating , think have code right using gridview.items.commitedit, information i've inputted empty cells still disappears. here code creates columns:

private void window_loaded(object sender, routedeventargs e)     {         //loads queries each of designated data tables in bsi_test         var customerquery =             (from customer in testentity.customers              join job in testentity.jobs              on customer.cid equals job.cid              join claim in testentity.claims              on job.jid equals claim.jid              select new              {                  customer_name = customer.cname,                  customer_id = customer.cid,                  job_id = job.jid,                  claim_id = claim.claimid,                  did = deductid,                  check_no = checkno,                  check_date = checkdate              })             .orderby(c => c.customer_name);           //populates telerik data grid data.         gridview.itemssource = customerquery.tolist();           gridviewdatacolumn deductid = new gridviewdatacolumn();         deductid.uniquename = "deductid";         deductid.header = "did";         deductid.datamemberbinding = new binding("deductid");         gridview.columns.add(deductid);          gridviewdatacolumn checkno = new gridviewdatacolumn();         checkno.uniquename = "checkno";         checkno.header = "check no";         checkno.datamemberbinding = new binding("checkno");         gridview.columns.add(checkno);          gridviewdatacolumn checkdate = new gridviewdatacolumn();         checkdate.uniquename = "checkdate";         checkdate.header = "check date";         checkdate.datamemberbinding = new binding("checkdate");         gridview.columns.add(checkdate);     } 

and here gridview_celleditended event attempts commit edits made columns. note: did test event out using breakpoints , make way through if statement when type information cell , click out of it. however, data have inputted still disappears, commitedit doesn't seem work properly.

bool handle = true; private void gridview_celleditended(object sender, gridviewcelleditendedeventargs e) {     if (e.editaction == gridvieweditaction.commit && handle)     {         handle = false;         gridview.items.edititem(this.gridview.currentitem);         gridview.items.commitedit();         handle = true;     } } 

if able me out this, appreciated. i'm confused wrong code.

edit: have updated code window_loaded event show linq query queries information database datagrid. itemssource set query list. below before mainwindow() method set properties deductid, checkno, , checkdate.

public string deductid { get; set; } public int checkno { get; set; } public string checkdate { get; set; }  public mainwindow() {     initializecomponent(); } 

edit: i've added in deductid, checkno, , checkdate properties linq query.

edit: here dataproperties class:

public partial class dataproperties {     public string cname { get; set; }     public int cid { get; set; }     public int jid { get; set; }     public int claimid { get; set; }     public string deductid { get; set; }     public string checkno { get; set; }     public string checkdate { get; set; } } 

you should set datamemberbinding property of each column binding object:

private void window_loaded(object sender, routedeventargs e) {     gridviewdatacolumn deductid = new gridviewdatacolumn();     deductid.uniquename = "deductid";     deductid.header = "did";     deductid.datamemberbinding = new system.windows.data.binding("deductid");     gridview.columns.add(deductid);      gridviewdatacolumn checkno = new gridviewdatacolumn();     checkno.uniquename = "checkno";     checkno.header = "check no";     deductid.datamemberbinding = new system.windows.data.binding("checkno");     gridview.columns.add(checkno);      gridviewdatacolumn checkdate = new gridviewdatacolumn();     checkdate.uniquename = "checkdate";     checkdate.header = "check date";     deductid.datamemberbinding = new system.windows.data.binding("checkdate");     gridview.columns.add(checkdate); } 

you need make sure type t of ienumerable<t> have set itemssource radgridview contains deductid, checkno , checkdate properties , each of these have public setter.

binding collection of objects of anonymous type won't work. need create class contains properties (customer_name, customer_id, job_id, claim_id, deductid, checkno , checkdate) , have public setters want able edit in radgridview:

var customerquery =            (from customer in testentity.customers             join job in testentity.jobs             on customer.cid equals job.cid             join claim in testentity.claims             on job.jid equals claim.jid             select new yourclass //<--             {                 customer_name = customer.cname,                 customer_id = customer.cid,                 job_id = job.jid,                 claim_id = claim.claimid,                 did = deductid,                 check_no = checkno,                 check_date = checkdate             })            .orderby(c => c.customer_name); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -