Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
251
Enable column setting in codebehind
posted

Hi,

 

Can someone suggest me how to add rowediting and adding columnsettings in codebehind. I tried with the following code but it failed

           RowAddingColumnSetting setting1 = new RowAddingColumnSetting(WebDataGrid1);
            setting1.ColumnKey = readonlyColumns[i].ToString();
            setting1.ReadOnly = true;
            WebDataGrid1.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(setting1);

the last line gives error saying Object reference not set to an instance of an object.....

:(((((

 

 

  • 33839
    Suggested Answer
    posted

    Hi,

    The first thing that I notice about your code is that you are instantiating a RowAddingColumnSetting, but are adding that to the Column Settings for Cell Editing.  If you want a setting for cell editing, you need to create a EditingColumnSetting.  Also, make sure that your behaviors are created, either on the apsx or in code behind, before trying to add the setting.  Let us know if you have further troubles.

     

    regards,
    David Young