Set value in one textbox from two others

Hi, I have a form and table with 3 fields, LastName, FirstName and FullName, the user sholud enter FirstName and LastName and the system should create FullName, thsi can be used by using a trigger i the SQL database but I would like to do it in the app. But how?

Hi @VictorW60,

This should be done in the FormSubmit method via code:

        protected async Task FormSubmit()
        {
            try
            {
                person.FullName = person.FirstName + " " + person.LastName;
                await DbService.UpdatePerson(person.Id, person);
            }
            catch (Exception ex)
            {
                errorVisible = true;
            }
        }

I tried to do it with page properties, create on that I named strFullName. Then I added a label and set the Text = ${strFullName}, that works fine.

image

Now I would like to set the textbox, but the vlue property is set to a databas field, so is the only way of doing this the way that you wrote early in this Topic?

Yes, this would be the only way. However you started the thread for Radzen Blazor Studio and now seem to be using Radzen. In Radzen you need to use Execute C# action - you can't modify the generated code without adding it to the code generation ignore list.

Sorry for mixing thinks up.
Now I'm in Radzon Studio, the old one, because that is the licences I have.

I wrote the code in c# (Radzen Blazor) it looked nice, I saved the project an opened in Radzen Balzer and ran the project. Then I open the project in VS and the code was gone so I need to add something t to code generation ignore list??

But If I understand you right it is better to do it buy using page properties, is that right?

Yes, you need to do this via page properties or insert Execute C# statement in the Submit event handler to set FullName accordingly.

Ok, I have done the first part adding and setting the page property. The second part is not so clear to me, setting the value on FullName because I can see a reference to ${person.FullName}, So how do I do?

image

Well if you want to set full name from code it should be a form field should it? I would remove the entire row and use Execute C# action to set the FullName property in the Submit event:

${person.FullName} = ${person.FirstName} + " " + ${person.LastName};

This action should be executed before saving the data via Invoke data source method.

1 Like

Perfect, works fine!!