Search code examples
episerver

Change a episerver varible from string to int


I have created a blocktype for wweklymeetings and have made a mistake to write the variable name as a string, when it really should be an int. I have deleted all the places where the block is used and now want to create a new block in which the weeklynumber is an int. Unfortunately it does not work, the Create button become disabled, and then nothing happens. How should I do to get the week number as an int and create a block?

public class WeeklymeetingsBlock : BlockData
{
    [Display(
     Name = "Vecka",
     Description = "Den aktuella veckan.",
     GroupName = SystemTabNames.Content,
     Order = 1
     )]

    [Required]
    public virtual int Weeknumber { get; set; }

Solution

  • Your block instances are fetching their data type from the database, not from the code it self. Hence if you change the datatype in the code on a block that you have instances of (which you had) you must change the datatype in the database. This is typically done in the admin gui.

    Logon to admin, click the "content type" tab and navigate to the blocktype you need to change

    It will probably look something like this

    enter image description here

    Open the field you want to change, if it was emitted from code you will find the following option

    enter image description here

    Click revert to default