Conditionally call the helper method with the relevant htmlAttributes overload value.
EditorFor helper method does not have an overload which takes the htmlAttributes dictionary. So you can use the TextBoxFor helper method instead.
@for(int i=0; i<Model.CuttomersOrders.Count(); i++)
{
<tr>
<td>
@if (!String.IsNullOrEmpty(Model.CuttomersOrders[i].CustName))
{
@Html.TextBoxFor(c => c.CuttomersOrders[i].CustName,new { @readonly=true})
}
else
{
@Html.TextBoxFor(c => c.CuttomersOrders[i].CustName)
}
</td>
</tr>
}
Remember, the existence of the readonly attribute will make the input element readonly irrespective of the value. So basically the below 2 lines will render a readonly input element.
<input readonly="False" type="text" value="Java" />
<input i readonly="true" type="text" value="Java" />