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
150
Set Default Grid Column Value
posted
I am using version 6.3.20063.53 of the grid and am binding it to a custom object. One of the columns in the grid is set to a DataType of Byte and the Type to a CheckBox. I want to set the column to a default value of True (checked) so when a new row is inserted into the grid it is checked already. However, in the properties for the grid column the property of Default Value is grayed out and using the client-side events (BeforeRow and AfterRow InsertHandler) I am not able to set this value. I can't even get a reference to the row just created using

var row = igtbl_getRowById(rowId);

Any ideas?

Thanks 

 

 

  • 28464
    posted

    Hello,

    DefaultValue cannot be set declaratively in the ASPX or in the designer because it is of type object - there is no way you can tell at design time what value gets there (it is a generic object) so the only way to specify it is programmatically. The  code samples above seem pretty good to me, InitializeLayout is a great event to place such code there.

    You can set DefaultValue per column in UltraWebGrid1_InitializeLayout event using

    e.Layout.Bands(0).Columns.FromKey("JobID").DefaultValue = ...