Developer forum

Forum » Development » Updating a customfield news v2 field.

Updating a customfield news v2 field.


Reply

Hey Guys,

 

I'm trying to make a simplyfied view for my news. The news i'm trying to show have customfields and it's those fields i can't figure out how to save/update.

 

Can anyone give me som pointers?

 

 

Now i have somthing like this, but that ain't doing much good.

 

Repeater innerRepeater = ( item.FindControl( "repCustomFields" ) as Repeater );
      foreach ( RepeaterItem innerItem in innerRepeater.Items ) {
        int customfieldID = int.Parse( ( innerItem.FindControl( "hidID" ) as HiddenField ).Value );
        string txtValue = ( innerItem.FindControl( "txtValue" ) as TextBox ).Text;

        if ( txtValue.Length > 0 ) {       

          for ( int i = 0; i < n.CustomFields.Count; i++ ) {

           n.CustomFields[ i ].Value = txtValue;
            n.CustomFields[ i ].Save();
          }
        }
      }


Replies

 
Reply
mn@co3.dk wrote:

Hey Guys,

 

I'm trying to make a simplyfied view for my news. The news i'm trying to show have customfields and it's those fields i can't figure out how to save/update.

 

Can anyone give me som pointers?

 

 

Now i have somthing like this, but that ain't doing much good.

 

Repeater innerRepeater = ( item.FindControl( "repCustomFields" ) as Repeater );
      foreach ( RepeaterItem innerItem in innerRepeater.Items ) {
        int customfieldID = int.Parse( ( innerItem.FindControl( "hidID" ) as HiddenField ).Value );
        string txtValue = ( innerItem.FindControl( "txtValue" ) as TextBox ).Text;

        if ( txtValue.Length > 0 ) {       

          for ( int i = 0; i < n.CustomFields.Count; i++ ) {

           n.CustomFields[ i ].Value = txtValue;
            n.CustomFields[ i ].Save();
          }
        }
      }

Figured it out :)

I had to call n.save() before med CustomField updates where saved.

 

You must be logged in to post in the forum