gridview - C# Change the displayed name of a column item -


i have kendo gridview 1 of columns boolean value. in column, information comes labeled either "true" (for 1 or true), "false" (for 0 or false), or blank (for null). not professional, , trying change these values in grid instead displayed yes, no, or none (respectively). code using try make happen is:

model:

namespace mvcapplication.models {     public class companies     {          public string isadmitted { get; set; } 

controller:

    [httppost]     public actionresult companies_read([datasourcerequest] datasourcerequest request)     {         using (var companydata = new companiesdatacontext())         {             list<companies> model = new list<companies>();             var companylist = companydata.companies_jbs.select(s => s).tolist();             foreach (var h in companylist)             {                 companies x = new companies();                 x.isadmitted = h.isadmitted == (bool)true ? x.isadmitted = "yes" : h.isadmitted == (bool)false ? x.isadmitted = "no" : x.isadmitted = "null";                 model.add(x);             }              return json(companydata.companies_jbs.todatasourceresult(request));         }     } 

view:

@(html.kendo().grid(model)     .name("company_grid")     .columns(columns =>         {             columns.bound(o => o.isadmitted).title("admitted:").width(95);             columns.command(command => { command.edit(); command.destroy(); });          }     )     .toolbar(toolbar => toolbar.create().text("add company"))     .editable(editable => editable.mode(grideditmode.popup).templatename("companies"))     .pageable()     .sortable()     .scrollable()     .htmlattributes(new { style = "height:430px;" })     .datasource(datasource => datasource         .ajax()         .pagesize(20)         .events(events => events.error("error_handler"))         .model(model => model.id(o => o.id))         .create(update => update.action("companies_create", "home"))         .update(update => update.action("companies_update", "home"))         .destroy(update => update.action("companies_destroy", "home"))         .read(read => read.action("companies_read", "home"))     ) ) 

when put breakpoint , check value, says isadmitted field items labelled yes, no, or none (depending on value in sql database). however, in grid still labeled true, false, or blank. whats problem here, or there better way this?

why returning json(companydata.companies_jbs.todatasourceresult(request));?

you have return model. so, return statement of controller method should be

return json(model.todatasourceresult(request)); 

Comments