Unable to get the value from a Variable

I have a Table and having some columns like "HSNCode", "MRP", "Total" etc.. I want to merge the "MRP" value to the immediate below row when "HSNCode" value is empty in any of the row. Just I am looping on one condition.

If HSNCode is not empty then I am storing the value in "another" variable. Like that it will be in the loop until "HSNCode" is empty. When HSNCode is empty then in the "another" variable previous value of MRP will be stored. I want to copy that MRP to the below row if HSNCode is Empty.

But the Problem is that value is not storing

using System;

string another = string.Empty;

int count = 20;

for(int i = 0; i<count; i++)
    if(Context.Field("HSNCode").Text != "")
        another = Context.Field("MRP").Text;   
    else if(Context.Field("HSNCode").Text == "")
        Context.Field("MRP").Text = another;

Was this article helpful?

0 out of 0 found this helpful


1 comment

  • Avatar


    In your code sample I do not see the “i” variable into the loop.


    Please see the sample:

    int rowsNumber = Context.Field("Name").Items.Count; //we count the number of table's rows
    string Value = "";//we create a variable to store the last found Classification value

    for (int index = 0; index < rowsNumber; index ++) //we iterate through all rows
        if (Context.Field("Name").Items[index].Text != "")
           Value = Context.Field("Name").Items[index].Text; //if "Name" is not empty, then we fill the variable with the found value
            Context.Field("Name").Items[index].Text = Value;//if "Name" is empty, then we write to the field the last found value


Please sign in to leave a comment.