SharePoint 2010 Access other fields of a form within a custom fieldtype

As you might have noticed, i already wrote some posts about custom fieldtypes. But i didn’t wrote about this: How can you access the other fields and its values and maybe change them or use them within your custom fieldtype code?

UPDATE: watch this post

My posts about custom fieldtypes:

I luckily found this great post. The explanation is really good. So i put it in my code and it worked. I just changed the code a little bit.

[sourcecode language=”csharp”]

//Function to interact with other fields
protected BaseFieldControl GetFieldControlByName(String fieldNameToSearch)
String iteratorId = GetIteratorByFieldControl(this).ClientID;
foreach (IValidator validator in Page.Validators)
if (validator is BaseFieldControl)
BaseFieldControl baseField = (BaseFieldControl)validator;
String fieldName = baseField.FieldName;
if ((fieldName == fieldNameToSearch) &&
(GetIteratorByFieldControl(baseField).ClientID == iteratorId))
return baseField;
return null;
//Function to search the field in the form
private ListFieldIterator GetIteratorByFieldControl(BaseFieldControl fieldControl)
Control iterator = this;
while (iterator != null && !(iterator is ListFieldIterator))
iterator = iterator.Parent;

return iterator as ListFieldIterator;

//Now writing values into the other field
TextField fieldText = (TextField)GetFieldControlByName(“MeinTest”);
fieldText.Value = “Wert1”;



You should use this lines of code in your custom fieldtype, if you want to

  • fill certain values into the other fields
  • get values of certain fields
  • change values dependent on an event (e.g. button click)

In the end it could look like in the screens below.

On click “inserting values” the values Wert 1 and Wert2 will be stored into the fields which are below of the button.

And it is saving the values into the list:

Hope this helps you.


The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

About Karsten Schneider 312 Articles
Consultant for Microsoft 365 Applications with a strong focus in Teams, SharePoint Online, OneDrive for Business as well as PowerPlatform with PowerApps, Flow and PowerBI. I provide Workshops for Governance & Security in Office 365 and Development of Solutions in the area of Collaboration and Teamwork based on Microsoft 365 and Azure Cloud Solutions. In his free time he tries to collect tipps and worthy experience in this blog.

Be the first to comment

Leave a Reply

Your email address will not be published.